BEAM Processes: Kilobytes vs. Megabytes

Erlang processes are exceptionally lightweight, typically consuming only a few kilobytes of memory each, with a newly spawned process using about 309 words (roughly 2.5 KB on a 64-bit system). This allows a single BEAM node to efficiently manage hundreds of thousands or even millions of concurrent processes, a stark contrast to OS threads that often demand megabytes per instance. [2, 4, 7]

The top 3

  1. BEAM Process: Kilobyte Footprint vs. Megabyte Threads: A BEAM process typically starts at just 2-3 KB of memory, including its stack and heap, allowing millions to run concurrently. In contrast, traditional OS threads often demand 1-2 MB of stack space per thread, making them 500-1000 times heavier.
  2. Millions Concurrent: BEAM's Scalability Advantage: The extremely lightweight nature of BEAM processes enables systems to effortlessly scale to millions of concurrent processes on a single machine, with 1 million Erlang processes using only ~2-3 GB of memory for overhead, a feat nearly impossible with heavier OS threads that quickly exhaust memory.
  3. BEAM's Context Switch: Nanoseconds vs. Microseconds: BEAM processes switch contexts in ~20 nanoseconds, due to their lightweight nature and VM-managed scheduling, whereas OS threads require 500-1000 nanoseconds or more due to kernel involvement.

Sources

Open the full topic