Design an Online Tic-Tac-Toe Platform
Match two players and execute authoritative turn-based games through retry-safe APIs across multiple regions.
Problem statement
For this exercise, assume authenticated players use REST APIs to join matchmaking and play standard two-player, three-by-three tic-tac-toe. The service pairs compatible waiting players, creates one authoritative game, accepts legal moves in turn, detects win or draw, and exposes game and matchmaking status.
Clients may retry after timeouts, issue concurrent requests, disconnect, or move between regions. A move response must not claim success unless the authoritative game version includes it, and the same request must never occupy two cells.
Design matchmaking, game state, move concurrency, API idempotency, multi-region placement, failover, history, expiration, and observability. Chat, tournaments, spectator streaming, skill ratings, and anti-cheat beyond request integrity are outside scope.
What to build
- A player can enter or cancel a queue and is assigned to at most one active two-player game for that matchmaking request.
- Each player can submit retry-safe moves, and the service accepts only the current player's legal move against the expected game version.
- Players can read the authoritative board, turn, outcome, version, and recent move history and can recover after disconnect.
- The service expires stale queue entries and abandoned games under an explicit timeout policy while retaining an auditable terminal result.
At scale
- For this exercise, assume 10 million monthly active players, 100,000 concurrent games, 20,000 matchmaking requests per second, and 50,000 move requests per second at peak.
- Target 300-millisecond p95 for matchmaking status and move responses within a player's home region.
- A game requires linearizable move order and must survive a zone failure without losing an acknowledged move.
- Serve players from three active regions; a regional failure may pause affected games for up to 30 seconds but must not create two writable authorities.