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.

The top 3

  1. BEAM Processes: 1000x Smaller Memory Footprint: Erlang's BEAM processes typically start with a memory footprint of only ~2-3 KB, allowing millions of concurrent processes on a single machine, whereas traditional OS threads often consume 1-2 MB each, drastically limiting the total number that can be run due to memory constraints.
  2. Faster Context Switching: BEAM's VM vs. OS Kernel: BEAM's internal scheduler handles context switching between its lightweight processes, making it significantly faster and more efficient than the OS kernel-managed switching required for traditional threads, which incurs higher overhead by saving/restoring more state and often flushing the Translation Lookaside Buffer (TLB).
  3. Fault Isolation: BEAM Processes' Crash Containment: BEAM processes are completely isolated and do not share memory, which enables Erlang's 'let it crash' philosophy. If one lightweight process fails, it does not affect others, allowing supervisors to restart only the faulty component and prevent system-wide crashes.

Sources

Open the full topic