Design a Real-Time Quiz Showdown with Buzzer Lockouts
System DesignModel answerLast updated
Design a multiplayer live quiz system where players race to buzz in, wrong answers trigger a timed lockout, and fairness holds across varying network conditions.
Real-Time Quiz Showdown with Buzzer Lockouts
You're building the backend for a live quiz game. Matches have between 2 and 8 players. Each round, all players see the same question at the same time and compete to be the first to buzz in. Only the first player the server accepts gets to attempt an answer. A correct answer scores the round and triggers the next question. A wrong answer locks that player's buzzer for exactly one second, then reopens the question for everyone else (including, once their lockout expires, the player who just missed).
Your design should cover how buzz attempts are handled and adjudicated, how lockout state is tracked, and how players get placed into a match.
State your assumptions
Scale, geographic regions, question bank size, and exact scoring formulas are intentionally left open. State your assumptions clearly before diving in — treating them as design decisions, not gaps.
Good clarifying questions to think through
- When a player's lockout ends mid-question, can they buzz in again, or is the question over?
- Can friends create a private room together, and how long does the system wait before starting with fewer than 8 players?
- Is player score per-match only, or does it feed into a persistent rating?
- How many concurrent matches should the system support, and what happens when a player disconnects mid-round?
Part 1 — Buzz-in flow and lockout mechanics
Walk through the full lifecycle of a single round: from the question appearing on every client, to a player buzzing in, to the round resolving (correct or incorrect), to the next round starting.
Cover:
- What connection model you use and why
- Where "who buzzed first" is decided, and why that authority lives there
- How the lockout is stored, applied, and lifted — with no unnecessary background jobs
- What happens when two buzz attempts arrive within milliseconds of each other
- How every player's UI stays consistent with server state
Part 2 — Matchmaking
Design the flow for getting players into a match, covering both public queues (strangers) and private rooms (friends). Address:
- How you avoid players waiting forever for a full 8-person lobby
- How private rooms differ from the public queue, and where they share logic
Follow-ups to address in your answer
- How would you maintain and update a persistent player rating across matches?
- A player with 10ms latency and a player with 80ms latency both press their buzzer at the exact same physical moment. The 10ms player wins every time under a naive design. How do you reduce this structural unfairness?
Hints
Hint 1
The server has to be the sole authority on who buzzed first — but 'first' shouldn't mean 'whose packet happened to arrive earliest due to geography.' Think about what timestamp you actually want to compare, and where the data to construct it comes from.
Hint 2
A lockout that expires in 1 second doesn't need a background timer firing at T+1000ms. Think about the smallest piece of state you'd store, and when and where you actually need to evaluate it — you'll find the check naturally happens at exactly the right moment.
Hint 3
Public matchmaking and private rooms look different on the surface but converge on the same 'spin up a match session' operation. Model them as two entry points to the same pipeline rather than two separate systems.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Assumptions
- Target: tens of thousands of concurrent matches globally, deployed across 3–5 regions.
- Matches are short (5–15 questions, under 10 minutes), so losing in-flight match state on a server crash is acceptable with a clear stated trade-off.
- Score is both per-match (shown on a results screen) and fed into a persistent rating.
- A player who disconnects mid-match is treated as inactive; their buzzer doesn't participate but the match continues for others.
- Questions are pre-loaded into the match session at start time from a shared question bank service.
Part 1 — Buzz-in flow and lockout mechanics
Connection model
Each match runs as a session owned by a single server process. All per-match state — current question, scores, and lockout records — lives in that process's memory. Players connect via WebSocket on match creation and hold that connection for the match duration. This avoids per-attempt HTTP handshake overhead, which matters when the difference between two buzz attempts might be 20ms.
One process owning one match is simple and fast. The trade-off is that a crash loses in-flight state; for short matches, this is acceptable. If the product requires crash recovery, periodic snapshots to a fast store (e.g. Redis) can be added later without redesigning the core flow.
Server-authoritative buzz adjudication
Clients never decide locally that they won. A client decides when to send a buzz attempt — that's it. Each attempt carries the player's ID and a client-side timestamp (useful for latency compensation, covered below). The server compares attempts by adjusted receive time and the first accepted attempt wins exclusive answering rights for that round.
The server immediately broadcasts "buzzer locked to player X" to every client. Other clients disable their own buzzer and show who is answering — no client needs to guess or race to update. This eliminates any scenario where two clients simultaneously believe they won the round.
Lockout representation
When a player answers incorrectly, the server writes:
locked_until[player_id] = server_now_ms + 1000
That's the entire lockout record. There is no scheduled unlock event, no background job, no timer callback. When a subsequent buzz attempt arrives from that player, the server evaluates:
if server_now_ms < locked_until[player_id]: reject
The lockout lifts itself at the moment it's relevant — the next time that player tries to buzz. Telling the client how many milliseconds remain (locked_until - now) lets the UI display a countdown without any additional server state.
After a wrong answer, the current question stays open. Any player whose locked_until is in the past (everyone else, plus the offender once their second is up) can buzz in. The round ends when someone answers correctly or a round timeout is reached.
Near-simultaneous buzzes
With two attempts arriving within a few milliseconds, the server picks the one with the smaller adjusted timestamp (see latency section). If adjusted timestamps are equal — genuinely rare — break the tie with a stable secondary key such as the order the server's network stack received the bytes. The exact tiebreak policy matters less than choosing one deterministic rule and sticking to it; the important property is that the outcome is auditable and not random.
Part 2 — Matchmaking
Two entry points, one match-creation pipeline.
Public queue: Players opt in to a matchmaking pool. A background process groups waiting players:
- As soon as 8 players are queued, start the match immediately.
- If fewer than 8 players are in the pool when a deadline (e.g. 20 seconds after the first player joined) expires, start the match with whoever is there, as long as there are at least 2.
- If after the deadline there is only 1 player, keep them in the queue and reset the clock.
The 20-second deadline is a deliberate trade-off: some matches start smaller than ideal, but no player waits indefinitely. This number is tunable based on observed queue depth.
Private rooms: A player creates a room and receives a short alphanumeric code. Other players join using that code. The host starts the match manually, at any point with 2–8 players present. No deadline logic, no queue — membership is intentional.
Both paths call the same create_match_session(player_list) function. Match logic never needs to know which path players came from.
Follow-up 1 — Persistent player rating
Use an Elo-style update applied pairwise. After each match, enumerate every pair of players. The player who scored higher in that match is the "winner" of that pairing. Apply a standard Elo delta for each pair:
delta = K * (actual_outcome - expected_outcome)
expected = 1 / (1 + 10^((rating_B - rating_A) / 400))
Sum the deltas from all pairings and apply them to each player's rating in a single write. A typical K-factor of 16–32 works well; use a higher K for new accounts (fewer than ~30 matches) to let ratings settle faster. This reuses a well-understood formula rather than inventing a new N-player system.
Follow-up 2 — Latency compensation
Under raw server receive time ordering, a player 10ms from the server beats an equally fast player 80ms away on every buzz, through no skill difference. To remove this structural bias:
- At connection time, run a short ping/pong exchange (3–5 round trips) and record each player's estimated RTT. Refresh this estimate every 30 seconds.
- Compute estimated one-way latency as
RTT / 2. - When comparing buzz attempts, use
adjusted_time = server_receive_time - one_way_latencyfor each player.
This doesn't make the game perfectly fair — jitter, route variance, and estimation error all remain — but it removes the dominant, structural component of the disadvantage. A player 80ms away who reacts faster than a player 10ms away should be able to win, and this design makes that possible.
One common mistake here is to trust the client-reported timestamp directly for ordering. A client can trivially backdate its timestamp. The server-side RTT estimate keeps the compensation mechanism server-controlled and cheat-resistant.