Introduction
Erlang is a functional programming language created at Ericsson in the 1980s for building telecom-grade systems. Together with OTP (Open Telecom Platform), it provides a framework for building applications that must run continuously with minimal downtime. Erlang powers systems at WhatsApp, Discord, and RabbitMQ.
What Erlang/OTP Does
- Runs millions of lightweight processes on the BEAM virtual machine
- Provides built-in fault tolerance through supervisor trees and process isolation
- Supports hot code swapping for upgrades without stopping the system
- Enables transparent distribution across multiple nodes
- Includes OTP behaviors (gen_server, gen_statem, supervisor) for common patterns
Architecture Overview
Erlang runs on the BEAM virtual machine, which schedules lightweight processes across CPU cores using preemptive scheduling. Each process has its own heap and communicates via asynchronous message passing. OTP provides standardized abstractions: gen_server for client-server patterns, supervisors for automatic restart strategies, and applications for packaging releases.
Self-Hosting & Configuration
- Install via package managers or use kerl/asdf for version management
- Configure releases with
rebar3ormix(for Elixir interop) - Set VM flags in
vm.argsfor memory limits, scheduler count, and node naming - Use
sys.configfor application-level environment variables - Deploy as self-contained releases with
rebar3 release
Key Features
- Lightweight processes (millions per node) with per-process garbage collection
- "Let it crash" philosophy with automatic process restart via supervisors
- Hot code loading for live system upgrades
- Pattern matching and immutable data by default
- Battle-tested in telecom, messaging, and financial systems for decades
Comparison with Similar Tools
- Elixir — Elixir runs on the BEAM and adds modern syntax; Erlang is the original with deeper OTP integration
- Go — Go has goroutines but lacks built-in supervision trees and hot code swapping
- Rust — Rust focuses on memory safety; Erlang focuses on fault tolerance and uptime
- Akka (Scala/Java) — Akka implements the actor model on the JVM but lacks BEAM's per-process isolation
- Node.js — Node is single-threaded with async IO; Erlang is truly concurrent with preemptive scheduling
FAQ
Q: Is Erlang still relevant today? A: Yes. Erlang powers WhatsApp, RabbitMQ, CouchDB, and many telecom systems. Its concurrency model remains unmatched for certain workloads.
Q: What is the relationship between Erlang and Elixir? A: Elixir is a separate language that compiles to BEAM bytecode and can call Erlang libraries directly. They share the same runtime.
Q: Can Erlang handle millions of connections? A: Yes. The BEAM VM was designed for this. WhatsApp reportedly handled two million connections per server using Erlang.
Q: How does hot code swapping work? A: The BEAM can load a new version of a module while the old version is still running. Active processes migrate to the new code on their next function call.