How to perform Hot Code Swapping in Elixir- #1

Malreddy Ankanna
blackode
Published in
6 min readDec 28, 2018

--

Always be up to date…

This article will guide you to perform hot code swapping using GenServer & :sys.change_code function.

The world is moving at a high speed. Every one is on race knowingly or unknowingly. If you stop or wait then you are letting yourself down. OK! I’ll stop being more dramatic here. It is just to make you understand how important the time is in the modern world especially in software development.

Hot code swapping is replacing or adding components without stopping or shutting down the system. It is frequently called as hot plugging.

In software development, hot swapping is used to upgrade or update the system without interrupting the current running system. It helps us with less downtime at the time of upgrading.

OK! Stories are always good to hear. Let’s dive into code.

Step 1 — Creating a GenServer

The hot code swapping can be achieved using the behavior module GenServer. Save the following lines of code into a file called demo_server.ex .

defmodule DemoServer do
use GenServer
@vsn "1"## Client APIdef start_link employee do
GenServer.start_link __MODULE__…

--

--

Malreddy Ankanna
blackode

Programmer & Writer, I write about coding, thoughts, ideas, personal musings, technical articles, and tutorials.https://bio.link/blackode