One of the nice features of Erlang is the possibility of replacing a piece of code with a newer version while the application is still running. This means you can release new versions of your software without any downtime.
Bellow is a simple example created to help me understand it. It is a simple OTP GenServer that just increments a counter. The commented parts are going to be our “upgrade”, modifying the module version (
@vsn) and its behavior to increment from 1 by 1 to, 2 by 2.
Let’s suppose the code above is saved to a file called
inc.ex, and you open iex on the same directory the file is, here are the steps taken to create an initial version, do our changes, and perform an upgrade:
As you can see, the value is now changing in increments of 2.
A better option to perform a hot upgrade, specially when deploying to production, might be to use exrm.
- Using Dialyzer with an Elixir Mix Project
- Services Version Lock with Docker and Jenkins
- Problems with Branches per Environment
- Option in Elixir
- Trunk Based Development with Multiple Services
- Erlang Link, Monitor, and Process Exit
- Integration testing for nginx Routes
- Erlang, Elixir and a simple Supervisor
- Efficient Timer using a Circular Buffer
- RFID, Dryers, and IoT