</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 6: Following g_8Kd2 Through the System - High-Level Architecture

Executive Summary: Clients hold one WebSocket to a Gateway, which authenticates them and does the timekeeping. Each live game is an actor on one Game Server, which persists every move to the regional Live Game Store before anyone sees it. The Placement Service (backed by etcd) maps games to servers, the Matchmaker pairs seekers, and Pub/Sub carries moves to spectators. One game-ended event on Kafka feeds everything else. We trace g_8Kd2 from seek to new rating, then defend the gateway/game-server split and the three-cell region model.

The interviewer slides the marker across. "You have the contract and the stores. Draw the boxes, then walk one game through them."

You say the rule before you draw: only the gateways, the game server and the live store touch a move. Spectators get a copy through Pub/Sub; everything else hears about the game after it ends.

The Boxes, Each With One Job

Online chess architecture: clients resolve through global DNS to gateways over one WebSocket and use the REST API for lobby, history and seeks; the Matchmaker places games via the Placement Service; gateways exchange moves with game-server actors, which write the live store, publish to Pub/Sub for spectators and emit game-ended to Kafka for the Tournament Director

Component Its one job The number that sizes it
Gateways Hold the WebSocket, verify the JWT, stamp sent_at/arrived_at, route by game_id 1M peak connections at 50K per node, 30 gateways
Game Servers Host the game actors; validate, persist, broadcast, arm timers 10K live games per node cap, 30 game servers
Live Game Store One live_games item per game, one conditional write per move ~28K writes/s peak fleet-wide, p99 ≤ 10 ms
Placement Service + etcd Map game_id → (server, epoch); hold node leases Lease TTL 3 s, heartbeat 1 s
Matchmaker Pair seekers inside a rating window 21 pools, 700 seekers paired/s at peak
Pub/Sub Carry each move to every gateway that has viewers ~60K/s spectator pushes
Kafka game-ended One event per finished game, keyed by game_id 350/s peak, ~1.5 KB each
Rating Service Glicko-2 update per rated game, in Postgres ~560/s peak
Archive Writer Copy into games + user_games; nightly PGN dump 10 GB/day
Fair-Play Pipeline Tiered post-game engine analysis ~300 cores
Tournament Director One actor per tournament: pairings, standings Up to 20,000 players per Arena
REST API / Identity Lobby, profiles, history, tournaments / OIDC login, 15-min JWTs Everything that is not real-time

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.