BEAM Process Memory: Kilobytes vs. Megabytes

Each BEAM process typically consumes only a few kilobytes of RAM, in stark contrast to operating system threads which often require several megabytes, enabling millions of concurrent processes on a single server.

The top 3

  1. BEAM vs. OS Threads: 1000x Memory Efficiency: A typical BEAM process starts at just 2-3 kilobytes, making it up to 500-1,000 times more memory-efficient than a traditional OS thread which often consumes 1-2 megabytes for its stack and overhead.
  2. The Secret to Micro-Sized Processes: Per-Process Heaps: BEAM processes achieve their minimal memory footprint by utilizing isolated, dynamically growing heaps and independent, generational garbage collection for each process, effectively eliminating shared memory overhead and complex global synchronization.
  3. Millions of Agents: BEAM's Scalability Advantage: The kilobyte-level memory footprint per BEAM process is the fundamental enabler for systems like WhatsApp to efficiently handle millions of concurrent agents or connections on a single server, a scale that is generally unachievable with traditional OS-thread-based architectures.

Sources

Open the full topic