Scaling Concurrency: Millions on BEAM, Thousands on OS Threads

The drastically smaller memory footprint of BEAM processes is a cornerstone for its unparalleled scalability, enabling the Erlang VM to concurrently manage millions of lightweight processes on a single machine. In contrast, the substantial memory overhead of OS threads severely limits their practical concurrency to thousands, as system memory is quickly exhausted.

The top 3

  1. BEAM Processes: Up to 1,000x Smaller Memory Footprint: Erlang BEAM processes are exceptionally lightweight, typically requiring only 2-3 KB of memory per process, compared to OS threads (e.g., JVM threads) which often consume 1-2 MB of stack space, making BEAM processes 500-1,000 times more memory efficient.
  2. BEAM's Context Switch: Orders of Magnitude Faster: BEAM's internal management of process context switching is significantly faster than OS kernel-managed thread context switching. While OS thread switches typically take microseconds, BEAM's optimized internal scheduling has minimal overhead, contributing to its high concurrency.
  3. BEAM's Million-Process Concurrency Record: The Erlang BEAM virtual machine can efficiently handle millions of concurrent processes on a single machine, a capability famously demonstrated by systems like WhatsApp. In contrast, traditional OS threads are typically limited to thousands due to higher memory and scheduling overheads.

Sources

Open the full topic