Katkat

Design a Live Speed-Typing Arena With Mistake Lockouts

OpenAISoftware Engineer · Technical Screen

Last updated

Design the backend for a multiplayer typing race where wrong keys lock a player out for 1.5 seconds. Covers authoritative match servers, the lockout mechanism, skill-based matchmaking, ratings and leaderboards, and compensating for network latency.

Design the backend for KeyClash, a live speed-typing arena. Players join a match and race to type a shared passage. Accuracy is enforced: a wrong keystroke locks that player's keyboard for 1.5 seconds, during which their input is ignored. The first player to finish the passage wins, and everyone else is ranked by finish time, or by progress if they time out.

Functional requirements

  1. Matchmaking. Quick-play puts a player into a public match of 3 to 6 players with similar skill. Private rooms are created with an invite code (friends only, 2 to 6 players).
  2. Match lifecycle. Lobby, then a 5-second countdown, then the race (hard cap 120 s), then results. A passage of 150 to 400 characters is chosen when the countdown starts and revealed to all players at the same instant.
  3. Lockout. After a wrong keystroke, the cursor stays on the missed character. The player is locked for 1.5 s, and the next correct key after the lockout ends advances the cursor.
  4. Live progress. Every player sees every opponent's progress bar and lockout state, refreshed at least 10 times per second.
  5. Results and rating. Record WPM, accuracy and placement per match. Maintain a persistent skill rating used for matchmaking, plus global and weekly leaderboards.
  6. Disconnects. A player who drops can rejoin within 10 s and continue. After that they are marked DNF.

Non-functional requirements

  • Scale: 1.5M daily active users. Peak is 120k concurrent players, which is about 25k live matches.
  • Latency: keystroke-to-opponent-view under 150 ms p95 within a region. Players are in North America, Europe and Asia-Pacific.
  • Fairness: a player 180 ms away from the server must not lose to a 20 ms player of equal skill because of the network alone.
  • Anti-cheat: the server is authoritative. Bots and macro scripts should be detectable.
  • Matchmaking wait: p90 under 15 s at peak. Relax the skill band as wait time grows.

What to deliver

  1. A high-level architecture with the components and the protocols between client and server.
  2. The match session design: where match state lives, how keystrokes are validated, and exactly how the lockout is enforced and released.
  3. The matchmaking algorithm and service.
  4. The ranking approach: a per-match score and a persistent rating, plus the leaderboard storage.
  5. How you handle network latency fairness, and the trade-offs of your choice.
  6. Failure handling: match server crash, client reconnect, region outage.

Explicitly state any assumptions you make about passage generation, scoring formulas and regions.

Hints

Hint 1

Can the lockout be modeled as a timestamp rather than a timer? Then what does unlocking require?

Hint 2

Where should a single match's state live so that every keystroke check is a memory lookup?

Hint 3

For matchmaking, think about queues keyed by region and skill band, and what to do as a player's wait time grows.

Hint 4

Separate when a keystroke happened from when the server received it. How can you trust the former?

Follow-up questions

  • How would you detect a typing bot that injects keystrokes with human-like random delays?
  • Add spectator mode for tournament finals with 100k viewers. What changes in the fan-out?
  • How would you deploy a new match-server version without interrupting live races?
  • Passages are generated by an LLM. How do you keep difficulty consistent so that ratings stay comparable?