TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using Erlang hot code updates

268 pointsby lawik6 months ago

13 comments

jhgg6 months ago
When I worked at Discord, we used BEAM hot code loading pretty extensively, built a bunch of tooling around it to apply and track hot-patches to nodes (which in turn could update the code on &gt;100M processes in the system.) It allowed us to deploy hot-fixes in minutes (full tilt deploy could complete in a matter of seconds) to our stateful real-time system, rather than the usual ~hour long deploy cycle. We generally only used it for &quot;emergency&quot; updates though.<p>The tooling would let us patch multiple modules at a time, which basically wrapped `:rpc.call&#x2F;4` and `Code.eval_string&#x2F;1` to propagate the update across the cluster, which is to say, the hot-patch was entirely deployed over erlang&#x27;s built-in distribution.
评论 #42189462 未加载
评论 #42191479 未加载
elcritch6 months ago
Code reloading on embedded Nerves devices is fantastic. If you have non-trivial hardware or state you can just hot load new code to test a fix live. Great for integration testing.<p>I literally used hot code reloading a few weeks back to fix a 4-20 mA circuit on a new beta firmware while a client was watching in remote Colorado. Told them I was “fixing a config”. Tested it on our device and then they checked it out over a satellite PLC system. Then I made an update Nerves FW, uploaded it. Made the client happy!<p>Note that I’ve found that using scp to copy the files to &#x2F;tmp and then use Code.compile to work better than copy and paste in IEx. The error messages get proper line numbers.<p>It’s also very simple to write a helper function to compile all the code in &#x2F;tmp and then delete it. I’ve got a similar one in my project that scp’s any changed elixir files in my project over. It’s pretty nice.
rozap6 months ago
I used to work on a pretty big elixir project that had many clients with long lived connections that ran jobs that weren&#x27;t easily resumable. Our company had a language agnostic deployment strategy based on docker, etc which meant we couldn&#x27;t do hot code updates even though they would have saved our customers some headache.<p>Honestly I wish we had had the ability to do both. Sometimes a change is so tricky that the argument that &quot;hot code updates are complicated and it&#x27;ll cause more issues than it will solve&quot; is very true, and maybe a deploy that forces everyone to reconnect is best for that sort of change. But often times we&#x27;d deploy some mundane thing where you don&#x27;t have to worry about upgrading state in a running gen server or whatever, and it&#x27;d be nice to have minimal impact.<p>Obviously that&#x27;s even more complexity piled onto the system, but every time I pushed some minor change and caused a retry that (in a perfect world at least...) didn&#x27;t <i>need</i> to retry, I winced a bit.
评论 #42189011 未加载
hauxir6 months ago
We use hot code upgrades on kosmi.io with great success.<p>It&#x27;s absolute magic and allows for very rapid development and ease of deploying fixes and updates.<p>We do use have to use distillery though and have had to resort to a bunch of custom glue bash scripts which I wish was more standardized because it&#x27;s such a killer feature.<p>Due to Elixirs efficiency, everything is running on a single node despite thousands of concurrents so haven&#x27;t really experienced how it handles multiple nodes.
edude036 months ago
Nerves and hot code reloading got me into erlang after I watched a demo of patching code on a flying drone ~8 years ago.<p>While I can&#x27;t imagine hot reloading is super practicle in production, it does highlight that erlang&#x2F;beam&#x2F;otp has great primitives for building reliable production systems.
评论 #42190527 未加载
评论 #42191350 未加载
评论 #42190737 未加载
throwaway815236 months ago
You have to be very very very careful when preparing relups. The alternative on Linux is to launch an entire new server on the same machine, then transfer the session data and the open sockets to it through IPC. I once asked Joe Armstrong whether this was as good as relups and why Erlang went the relup route. I don&#x27;t remember the exact words and don&#x27;t want to misquote him, but he basically said it was fine, and Erlang went with relups and hot patching because transferring connections (I guess they would have been hardware interfaces rather than sockets) wasn&#x27;t possible when they designed the hot patch system.<p>Hot patching is a bit unsatisfying because you are still running the same VM afterwards. WIth socket migration you can launch a new VM if you want to upgrade your Erlang version. I don&#x27;t know of a way to do it with existing software, but in principle using something like HAProxy with suitable extensions, it should be possible to even migrate connections across machines.
评论 #42189408 未加载
评论 #42242565 未加载
robocat6 months ago
Background to the article: <a href="https:&#x2F;&#x2F;underjord.io&#x2F;unpacking-elixir-iot-embedded-nerves.html" rel="nofollow">https:&#x2F;&#x2F;underjord.io&#x2F;unpacking-elixir-iot-embedded-nerves.ht...</a><p>Seems like they deploy Elixir on embedded Linux. The embedded Linux distro is Nerves which replaces systemd and boots to the BEAM VM instead as process 1, putting Elixir as close to the metal as they can.<p>I know nothing about any of the above (assumption is I&#x27;m fool enough to try and simplify) plus I know I&#x27;ve misused the concepts I wrote but that&#x27;s my point so read the article. All simplifications are salads
评论 #42192713 未加载
aeturnum6 months ago
IMO Hot Code Updates are a tantalizing tool that can be useful at times but are extremely easy to foot-gun and have little support. I suspect that the reason why no one has built a nice, formal framework for organizing and fanning out hot code changes to erlang nodes is that it&#x27;s very hard to do well, involves making some educated guesses about the halting problem, and generally doesn&#x27;t help you much unless you&#x27;re already in a real bind.<p>Most of the benefits of hot code updates (with better understanding of the boundaries of changes) can be found through judicious rolling restarts that things like k8s make easier these days. Any time you have the capacity to hot patch code on a node, you probably have the capacity to hot patch the node&#x27;s setup as well.<p>That said I think that someone could use the code reloading abilities of erlang to make a genuinely unparalleled production problem diagnostic toolkit - where you can take apart a problem as it is happening in real time. The same kinds of people who are excited about time traveling debugging should be excited about this imo.
whorleater6 months ago
WhatsApp very long ago used to hot reload across all nodes with a ssh script to incrementally deploy during the day
toast06 months ago
&gt; Both have described hot code updates as something that people should learn and use. I imagine Whatsapp’s initial engineering crew would agree. They did pretty well.<p>Yeah. Hot loading is clearly better than anything else when you&#x27;ve got a million clients connected and you want to make a code change. Of course, we didn&#x27;t have any of these fancy &#x27;release&#x27; tools, we just used GNU Make to rsync the code to prod and run erlc. Then you can grab a debug shell and l(module). (we did write utilities to see what code was modified, and to provide the right incantations so we wouldn&#x27;t load if it would kill processes)
评论 #42188817 未加载
arnon6 months ago
A few years ago, the biggest problem with Erlang&#x27;s hot code updates was getting the files updated on all of the nodes. Has this been solved or improved in any way?
评论 #42188728 未加载
评论 #42189232 未加载
samgranieri6 months ago
I tried to do this back in 2017 as an elixir newbie with distillery, but for some reason just went with standard deploys with distillery. Now it’s just using mix release to build elixir apps in a docker image deployed to k8s.
Thaxll6 months ago
Hot code update is one of those thing I don&#x27;t understand, just use a rolling deployment, problem solved. You have a new version of the code without loosing any connection.<p>It&#x27;s one of those thing that sound nice on paper but a actually couple your runtime with ci&#x2F;cd, if you have anything else beside Erlang what do you do? You now need a second solution to deploy code.
评论 #42189251 未加载
评论 #42189231 未加载
评论 #42189195 未加载
评论 #42189132 未加载