Why the BEAM for game servers, 2010 edition
Hernán’s first Erlang server, for a Cartoon Network football game, held 50,000 concurrent TCP connections per machine. The cap was the file descriptor limit the team chose not to raise. The Java estimate was a few thousand.
Runtime points
-
Processes for game developers: Hernán compares them to time slicing AI across frames with a per-tick budget, except the scheduler does it for you and handles socket-heavy workloads far better than hand-rolled code.
-
Timer granularity: interval timers take integer milliseconds, so 1000/30 became 33 and the server drifted against clients running 33.3. Choose a tick rate whose period is a whole number of milliseconds.
-
NIF vs Wasm: a NIF crash takes down the VM. A Wasm trap stays in the calling process, so one match dies, its players reconnect, and everyone else carries on.
-
Monitor, don’t restart: the lobby monitors matches rather than supervising them, because restarting from a bad Rust state would only crash again.
-
The scaling ceiling: once a tick’s work exceeds 25 ms, ticks queue and the match never catches up. Per-player cost includes the state copied across the Elixir/Wasm boundary on every tick.
-
Clock sync: an NTP-style ping exchange against a single server, keeping the smallest round trip. Tick resolution makes 10–15 ms of error tolerable.
Context
Demonware, Riot and Nintendo have long run connections, messaging, presence and notifications on the BEAM. Spawndemonium puts the game loop there too.