Discord's BEAM Concurrency: 12 Million Users
Discord achieved over 12 million concurrent users and 26 million WebSocket events per second using Elixir and the Erlang VM, demonstrating similar extreme scalability to WhatsApp with its lightweight processes.
The top 3
- BEAM's Micro-Processes: Discord's Concurrency Core: Discord achieves millions of concurrent users by leveraging BEAM's extremely lightweight processes, each starting at around 0.5 KB of memory, allowing a single server to efficiently run hundreds of thousands of isolated processes for users and guilds.
- Fault Tolerance: Isolated Processes for Uninterrupted Chat: BEAM's architecture ensures high fault tolerance for Discord: each process has its own isolated heap and communicates only via message passing, meaning a crash in one user's process does not affect other users or the entire server.
- Elixir & Rust Hybrid: Optimizing Performance at Scale: To handle CPU-heavy tasks and memory-intensive data structures without blocking the BEAM VM, Discord strategically integrates Rust via NIFs, offloading operations like data serialization and permission checks while keeping Elixir for high-level orchestration and concurrency.
Sources
Open the full topic