Design an Online Chess Platform: Elo Matchmaking, WebSocket Moves, Game Clocks
OpenAISoftware Engineer · OnsiteLast updated
Design an online chess platform: match players of similar Elo rating quickly, deliver moves in real time over WebSocket connections, and enforce fair game clocks despite network latency and disconnections. It tests matchmaking, stateful real-time architecture, server-authoritative timing and failover.
Design an online chess platform in the style of Chess.com. Players look for a game and are matched with an opponent of similar strength by Elo rating, play the game in real time with moves delivered over WebSocket connections, and each player has a game clock that must be enforced fairly.
Focus the design on three areas: rating-based matchmaking, real-time move delivery over WebSockets, and game clocks (timers). Cover the rest of the platform (accounts, game history) only as needed.
Clarifying Questions
- How many concurrent players and games at peak, and which time controls (bullet, blitz, rapid, daily)?
- Must players be matched within a few seconds, or is waiting longer for a closer rating acceptable?
- How should network latency be treated on the clock: should a player be charged for time their move spent in transit?
- What happens when a player disconnects in the middle of a game?
- Are spectators, chat and anti-cheat in scope?
Hints
Hint 1
Who is the source of truth: Decide which component owns each game's state and clocks, and what every other component is allowed to do with a move before that owner has accepted it.
Hint 2
Matching is a trade-off over time: Consider how the acceptable rating gap for a waiting player should change the longer that player waits.
Follow-up questions
- A game server crashes in the middle of a bullet game. What do the players experience, and how does the game resume?
- How would you support 100,000 spectators watching one top-level game?
- How would you detect players who are using a chess engine?
- How would you prevent rating manipulation, such as two accounts deliberately losing to each other?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.