Gleam 2.0 Hot Code Swapping Eliminated Our Deployment Downtime
For years, backend engineers have accepted a frustrating reality: the "maintenance window." Even with sophisticated rolling updates and blue-green deployment strategies, the risk of dropped connections or state loss during a transition remains a constant anxiety. However, the release of Gleam 2.0 hot code swapping has fundamentally shifted this paradigm for our engineering team. By leveraging the battle-tested power of the Erlang VM (BEAM) with a modern, type-safe interface, we have effectively eliminated deployment downtime and revolutionized how we manage long-running processes.
In this article, we will explore how Gleam 2.0’s implementation of hot code swapping works, why it surpasses traditional container-restart methods, and the specific technical steps we took to achieve a seamless, zero-downtime environment.
The Architecture of Resilience: Why the BEAM Matters
To understand why Gleam 2.0 hot code swapping is such a game-changer, one must first understand the Erlang VM (BEAM). Unlike traditional runtimes like Node.js or the JVM, the BEAM was designed from the ground up for high-availability telecommunications systems.
Gleam, a type-safe functional language, compiles to Erlang and inherits its actor model architecture. In this model, every part of your application is a lightweight process that communicates via message passing. Because these processes are isolated, the runtime can load a new version of a module into memory while the old version is still running. This isn't just a "fast restart"; it is a live replacement of the application's logic while it is actively processing data.
The Problem with Container Orchestration
While Kubernetes and Docker offer rolling updates, they typically involve killing an old container and starting a new one. This approach creates two major issues:

