KatInterview

Real-Time Multiplayer Typing Race Backend with Penalty Freezes

System DesignModel answer
HardModel answerSystem Designreal-timewebsocketmatchmaking

Last updated

Design a backend for a multiplayer typing race where a mistyped key freezes input for 1.5 seconds, covering match servers, matchmaking, ratings, latency fairness and failure recovery.

You are designing the backend for SprintType, an online game in which several people race to type the same text. Typing is penalized for sloppiness: whenever a player presses a wrong key, their input is frozen for 1.5 seconds and every keypress during that window is discarded. The first player to complete the text wins. Others are ranked by completion time, or by how far they got if the clock runs out.

Product behavior

  1. Finding a game. A quick-play button places a player in a public match of 3 to 6 players of comparable skill. Friends can instead create a private room via an invite code (2 to 6 players).
  2. Phases of a match. Lobby, then a 5-second countdown, then the race (hard limit 120 s), then a results screen. A text of 150 to 400 characters is picked when the countdown begins and shown to everyone at the same moment.
  3. Freeze rule. After a wrong key, the cursor stays on the character that was missed. Input is dead for 1.5 s. The first correct key pressed once the freeze is over moves the cursor forward.
  4. Live view. Each participant sees all opponents' progress and frozen/unfrozen status, updated at least 10 times per second.
  5. Scoring and ratings. Store WPM, accuracy and placement for each match. Keep a long-lived skill rating that drives matchmaking, along with all-time and weekly leaderboards.
  6. Dropped connections. A player who disconnects may come back within 10 s and pick up where they were. After that they are recorded as DNF (did not finish).

Non-functional targets

  • Scale: 1.5M daily active users, up to 120k simultaneous players (about 25k matches running at once).
  • Latency: a keypress should show up on opponents' screens in under 150 ms at p95 inside a region. Players are spread over North America, Europe and Asia-Pacific.
  • Fairness: a player with 180 ms of latency should not lose to an equally skilled player with 20 ms purely because of the network.
  • Integrity: the server is the source of truth. Bots and macro tools should be detectable.
  • Queue time: p90 under 15 s at peak, widening the allowed skill gap as waiting time grows.

What you should produce

  1. A high-level architecture: components and the protocols used between client and server.
  2. The match session design: where match state is kept, how each keystroke is checked, and precisely how the freeze is applied and ended.
  3. The matchmaking algorithm and its service.
  4. The ranking design: a per-match score, a persistent rating, and how leaderboards are stored.
  5. Your approach to latency fairness and its trade-offs.
  6. Failure handling: match server crash, client reconnect, whole-region outage.

State clearly any assumptions you make about text generation, scoring formulas and regions.

Hints

Hint 1

Keep each match entirely on one stateful server and think about how the gateway finds that server. Then ask whether the freeze really needs a timer at all, or whether a stored deadline compared against the current time is enough.

Hint 2

Separate what must be low-latency (progress broadcasts) from what can be asynchronous (ratings, leaderboards). Batching snapshots on a fixed tick is much cheaper than fanning out every keystroke.

Hint 3

For fairness, decide what quantity determines the winner: arrival time at the server or elapsed typing time on the client. Think about how to align start times across clients, how to bound client-reported times, and what that opens up for cheaters.