Multiplayer games with Netcode on the BEAM
Hernán Rivas Acosta's first Erlang game server, a football game for Cartoon Network, reached 50,000 concurrent players on one machine. The BEAM didn't stop it there. The OS file descriptor limit did, and the team chose not to raise it. The Java option they had considered would have managed a few thousand.
Roughly fifteen years later, Hernán, now an architect at Erlang Solutions, has put the game loop itself on the BEAM. Spawndemonium, shown at Code BEAM Europe in Haarlem, is a top-down shooter whose simulation is written once in Rust, compiled to WebAssembly, and run both in the browser and inside an Elixir GenServer via Wasmex. Client and server can't disagree about the rules, only about time.
The scar: AstroBeam's 30 Hz tick needed 33.3 ms, the Erlang timer took 33, and lag crept upward through every match. One-minute playtests never caught it. The fix was 40 ticks a second at 25 ms each, plus rewriting every per-tick constant in the game.
With Allen Wyma and Francesco Cesarini, Hernán covers ticks versus timestamps, why jitter breaks more games than latency, how to fake a bad network convincingly, and why the demons in Spawndemonium act on inputs five ticks old.
Topics include: • From Flash games for Cartoon Network and Nickelodeon to Erlang at 18 • 50,000 TCP connections per machine, capped by file descriptors • Peer-to-peer anti-cheat built on mutual reporting • Ticks, tick rate, ping vs latency, and jitter • Authoritative servers vs peer-to-peer, and Modern Warfare 2's host advantage • BEAM processes explained through game-engine time slicing • Why browser games are stuck on TCP via WebSockets • Borrowing netcode from Gran Turismo for a multiplayer Asteroids • Delay input, apply and rewind, or meet in the middle • Clock sync using the smallest round trip • Simulating jitter with a log-normal distribution and TCP head-of-line blocking • One server tick: queue inputs, run Wasm, decode binary events, push to sockets • A custom binary protocol with Elixir pattern matching instead of JSON • Wasmex vs a Rustler NIF: a crash costs one match, not the node • Bots as laggy players, deciding moves five ticks ahead • Small universes vs MMO-scale worlds • Multiplayer first, game second
Recorded October 26, 2026.
Resources: Spawndemonium on GitHub: https://github.com/HernanRivasAcosta/SpawnDemonium Episode 15 — Ellyse Cedeno on MMO servers: https://youtu.be/4MDObD_R5E4 Episode 10 — Florian Gilcher and Leandro Pereira on Rust and Elixir: https://youtu.be/w5Pl09lpSmE Mat Trudel on Bandit: https://youtu.be/XXQcoz_dTE0