Live data from Hacker News

Elixir/Erlang Hot Swapping Code (2016)

kennyballou.com

81–90 of 119 posts

Re: Elixir/Erlang Hot Swapping Code (2016)

#81

Live updating a drone running Erlang in 10ms while it was flying with no application restart and no loss of state impressed me when I saw it in 2021: https://www.youtube.com/watch?v=XQS9SECCp1I But I almost never hear Erlang/Elixir/Gleam folks talk about this benefit of the Erlang VM now, even though it seems fairly unique and interesting. Has the community moved away from it? Is it just not that useful?

A lot of web apps are just well-enough served with a blue-green deployment model. It is less risky. But if you really need it, it's really great to have that option (e.g. very long running systems which are split in front/back etc), and it can be used in creative ways too (like the Drone example). Here is a lightning talk I gave about how to use hot-reload for music / MIDI interactions: https://www.youtube.com/watch?…

Great talk, thanks, nice to see other creative uses. Great idea to add LiveView and SVGs for the keyboard UI.

"…thanks to hot reloading, which — for once — is useful…"

That seems to sum up the sentiment that hot swapping in Erlang has uses but they're generally not aligned with what Erlang is typically employed for. It seems like it would be great for tight game dev loop feedback and iteration too, for example, but that's not a traditional use of Erlang either.

Re: Elixir/Erlang Hot Swapping Code (2016)

#82
post #14

i'm so sick of this DevOps bullshit i wonder if there is an alternative language that you can hot swap code and do all the black magic stuff while keeping the reliability and performance like Rust.

The black magic comes at the cost of not having one streamlined procedure to release stuff. And to make the black magic work you have to engage with it. Most of the time people don't even bother write to a proper import.meta.hot.accept thingy in javascript. Developers simply hate chores, which is evident by not willing to write proper unit tests (despite knowing that tests work) or writing just enough to let the cove…

> The black magic comes at the cost of not having one streamlined procedure to release stuff.

You can also have a streamlined procedure to release stuff. Most changes in my erlang based system consist of "push to staging branch, click to deploy and test, pull to master, click deploy button". Can't be simpler than that. Most changes in such systems are also pretty simple. When you need to add something big, typically not many things are dependent on that, so deploy is also pretty simple.

> But most of the time you will do better job with PHP in a stupid restartable box behind seven load balancing proxies.

Yeah, we talk here about more complicated things here. If you have something simple, you don't need to use erlang, `python -m http.server` will be even simpler than your php in stupid restartable box, because you don't need a special box, just one small command.

Re: Elixir/Erlang Hot Swapping Code (2016)

#83
post #78

Live updating a drone running Erlang in 10ms while it was flying with no application restart and no loss of state impressed me when I saw it in 2021: https://www.youtube.com/watch?v=XQS9SECCp1I But I almost never hear Erlang/Elixir/Gleam folks talk about this benefit of the Erlang VM now, even though it seems fairly unique and interesting. Has the community moved away from it? Is it just not that useful?

A lot of the GenServer-information floating around explains code_change/3, no? That's commonly what you want, a way to handle state propagation when process code is updating in a running system. Most people are probably running some web services or something and might as well shift machines in and out of a cluster or can wait for old processes to disband on their own, because the new code is backwards compatible with…

[deleted]

Re: Elixir/Erlang Hot Swapping Code (2016)

#84
post #31

It's worth noting that distillery is deprecated in favor of mix releases, which don't support relups out of the box, and specifically warn against them due to the complexity involved in writing code to support them correctly. It's a cool feature that's no doubt amazing for applications that need it, but it brings a fair amount of complexity vs other deployment strategies.

Good point. Someone shared this in case someone wonders:

https://elixirforum.com/t/how-to-tweak-mix-release-to-work-w...

> I’ve spent some time understanding how to do hot code reloading with releases built using mix release, and here I’d like to detail the steps needed, in hopes that it will help someone.

Re: Elixir/Erlang Hot Swapping Code (2016)

#85

Earlier quoted context omitted.

A lot of web apps are just well-enough served with a blue-green deployment model. It is less risky. But if you really need it, it's really great to have that option (e.g. very long running systems which are split in front/back etc), and it can be used in creative ways too (like the Drone example). Here is a lightning talk I gave about how to use hot-reload for music / MIDI interactions: https://www.youtube.com/watch?…

Great talk, thanks, nice to see other creative uses. Great idea to add LiveView and SVGs for the keyboard UI. "…thanks to hot reloading, which — for once — is useful…" That seems to sum up the sentiment that hot swapping in Erlang has uses but they're generally not aligned with what Erlang is typically employed for. It seems like it would be great for tight game dev loop feedback and iteration too, for example, but t…

> That seems to sum up the sentiment that hot swapping in Erlang has uses but they're generally not aligned with what Erlang is typically employed for

Actually, I think it is much more common in original Erlang scenarios (including "non-web") where high availability is a useful pre-requisite.

It is in my experience less common in Elixir, which is often more web-oriented (although not exclusively).

Re: Elixir/Erlang Hot Swapping Code (2016)

#86
post #39

At kosmi.io we use elixir hot swapping for every small patch/bugfix on the backend. This allows us to deploy updates multiple times a day with 0 disruption. Allows the clients to remain connected and be none the wiser that there was an update at all. For larger updates we just do hard restarts when in-memory data structures or supervision tree are changed.

Would love to know more how you go about it.

It's a little hacky but I'll try to explain:

* The server runs in a docker container which has an ssh server installed and running in the background. The reason for SSH is simply because that's what edeliver/distillery uses.

* The CI(local github runner) runs in a docker container as well which handles building and deploying the updated releases when merged on master.

* We use edeliver to deploy the hot upgrades/releases from the CI container to the server container. This happens automatically unless stopped which we do for larger merges where a restart is needed.

* The whole deployment process is done in a bash script which uses the git hash for versioning, edeliver for deploying and in the end it runs the database migrations.

I'm not going to say it's perfect but it's allowed us to move pretty damn fast.

Re: Elixir/Erlang Hot Swapping Code (2016)

#87
post #14

Earlier quoted context omitted.

The black magic comes at the cost of not having one streamlined procedure to release stuff. And to make the black magic work you have to engage with it. Most of the time people don't even bother write to a proper import.meta.hot.accept thingy in javascript. Developers simply hate chores, which is evident by not willing to write proper unit tests (despite knowing that tests work) or writing just enough to let the cove…

> The black magic comes at the cost of not having one streamlined procedure to release stuff. You can also have a streamlined procedure to release stuff. Most changes in my erlang based system consist of "push to staging branch, click to deploy and test, pull to master, click deploy button". Can't be simpler than that. Most changes in such systems are also pretty simple. When you need to add something big, typically…

Do you do 100% of deployments using hot reload? If yes, maybe you should share the recipy with everybody else, since consensus seems to recommend the opposite.

At the very least you will have a different procedure to upgrade the erlang itself, right?

>If you have something simple, you don't need to use erlang

I think on a spectrum of difficult things there is an area between hosting static file on rpi at home and running massivele distributed system full of long running stateful processes.

Re: Elixir/Erlang Hot Swapping Code (2016)

#88

i'm so sick of this DevOps bullshit i wonder if there is an alternative language that you can hot swap code and do all the black magic stuff while keeping the reliability and performance like Rust.

It's not well known, but the JVM has very good hot reload support, and is a very reliable and performant platform.

Re: Elixir/Erlang Hot Swapping Code (2016)

#89
post #87

Earlier quoted context omitted.

> The black magic comes at the cost of not having one streamlined procedure to release stuff. You can also have a streamlined procedure to release stuff. Most changes in my erlang based system consist of "push to staging branch, click to deploy and test, pull to master, click deploy button". Can't be simpler than that. Most changes in such systems are also pretty simple. When you need to add something big, typically…

Do you do 100% of deployments using hot reload? If yes, maybe you should share the recipy with everybody else, since consensus seems to recommend the opposite. At the very least you will have a different procedure to upgrade the erlang itself, right? >If you have something simple, you don't need to use erlang I think on a spectrum of difficult things there is an area between hosting static file on rpi at home and run…

> Do you do 100% of deployments using hot reload?

About 99%. We need to restart servers maybe once a year. Maybe next year we will finally migrate from erlang 21 to latest. Most "stopping everything" deployments take max 1s of downtime, like this month when we needed to upgrade postgresql database by switching it over to new machine, having zero downtime here would take a little longer to get the consistency, but we could spare a second to make it much simpler task on database side (it was a restart of database module, rest of erlang server was unaffected and clients were not disconnected). Otherwise, most deployments are not visible as disconnections, we have a lot long-running connections.

> At the very least you will have a different procedure to upgrade the erlang itself, right?

Yes.

> I think on a spectrum of difficult things there is an area between hosting static file on rpi at home and running massivele distributed system full of long running stateful processes.

Is PHP good for both? I think PHP is NOT good for long running stateful processes, but I didn't use it in 10years. And it probably is not needed for static files.

Post reply on HN