Leaderboard System Design Interview: Requirements First
A requirements-first leaderboard walkthrough: pin down the ranking window, read/write ratio and tie rule, then defend each choice out loud in about 35 minutes.
In a leaderboard system design interview, the interviewer is testing how you turn a vague prompt into requirements, pick a data model that fits the read and write pattern, and defend the trade-offs out loud. The 30-second version of your answer: clarify the ranking window, choose a write path and a read path, then defend the tie rule. Three decisions drive everything else — global versus per-segment ranking, exact versus approximate rank, and real-time versus batched updates. Say those out loud early and the rest of the walkthrough has a spine.
What is the interviewer actually testing when they say 'design a leaderboard'?
They are not checking whether you have memorised a component diagram. A leaderboard is a small enough problem that the interesting part is the reasoning: how you scope it, how you model it, and how honestly you name what your choices cost.
Most candidates jump straight to a sorted set and stop. That reads as recall, not design. The stronger move is to slow down at the start, write the requirements on the board, and point back to them when you defend a trade-off later. When you say "I'm optimising for top-N reads because that's the dominant query," you want a requirement on the board that proves it.
The three decisions that drive everything else:
- Global versus per-segment ranking. One board for everyone, or a board per region, mode or time window. Segments multiply the number of structures you maintain.
- Exact versus approximate rank. Do they need a player's precise position, or is "you're around 4,200th" good enough? Exact rank is the expensive part.
- Real-time versus batched updates. Must a score show up within a second, or is a refresh every few seconds fine? This decides your write path.
Name these three in the first few minutes. The interviewer now knows you see the shape of the problem, and they can steer you toward the part they care about.
Which requirements should you pin down before drawing anything?
Ask concrete questions and write the answers where you can both see them. Vague prompts are normal; turning them into numbers is your job.
A checklist to run through:
- Scale: how many players, and how many score updates per second at peak?
- Freshness: how quickly must a new score appear on the board?
- Query shape: top-N only, or does each player also need their own rank?
- Ranking window: all-time, daily, weekly, per region, per mode?
- Tie rule: when two players have the same score, who ranks higher?
- Corrections: can a score be corrected or removed after it is written?
Here is how to turn vague answers into something you can design against. If the interviewer says "top players, fairly fresh," reply: "Let's say top 100 plus each player's own rank, refreshed within a few seconds, with a few thousand score updates a second at peak. Does that match what you have in mind?" You have just converted adjectives into a read pattern, a freshness budget and a write rate. If they correct you, even better — you are now designing against their numbers, not your guesses.
Writing requirements on the board first gives you something to point back to. When you defend a choice later, you can say "this follows from the top-100-plus-my-rank requirement" instead of asserting a preference.
How do you model scores and ranks so the read path stays cheap?
Start with the fields: player id, score, timestamp of last update, and the tie-break field. The timestamp is not decoration — it is how you break ties deterministically.
Then compare the two common storage shapes:
- A sorted structure keyed by score. Reads of the top N are cheap; a player's own rank is also cheap if the structure supports position lookup. Writes cost an insert and a reorder.
- A table plus a periodic ranking job. Writes are simple appends or updates. Exact global rank comes from a job that recomputes positions on a schedule, so rank is stale between runs.
Narrate the choice rather than announcing it. A short script: "I'm optimising for top-N reads because that's the dominant query. I'll keep scores in a structure sorted by score and tie-break field, which makes the top 100 cheap. The cost is that every score update touches that structure, so I'll come back to how I batch those writes."
That sentence does three things: it names the dominant query, states the choice, and admits the cost. Interviewers tend to reward the third part most, because it shows you are not pretending the design is free.
For how the same narration habit works on other prompts, see the Notification System System Design Interview: A Narrated Walkthrough.
How do you keep the leaderboard fresh without melting the write path?
This is where the read/write ratio decides the architecture. If reads vastly outnumber writes, you can afford to make writes do more work. If writes arrive in bursts, you may want to absorb them and update the ranking store in batches.
Picture a tournament ending: a burst of score events arrives in a few seconds. With synchronous updates, every event writes straight to the ranking structure. The board is fresh immediately, but the write path takes the full burst and a slow update delays the player's response. With an asynchronous pipeline, events land in a queue, a worker batches them, and the ranking store updates on a short interval. The burst is absorbed, but the board is stale for the length of that interval.
| Approach | Freshness | Write cost | Complexity | Failure behaviour |
|---|---|---|---|---|
| Synchronous | Immediate | High per event | Lower | A slow store slows the player-facing write |
| Batched | Stale by the batch interval | Amortised across a batch | Higher (queue, worker, retries) | Events wait in the queue; you need retry and dedupe |
Sketch this table if you have time. It gives the interviewer a single place to push on, and it shows you can compare options on general attributes rather than defend one blindly. The honest line: "I'll take a few seconds of staleness to keep the write path from taking the full burst. If the product needs instant freshness, I'd revisit this."
What breaks at scale, and how do you say it out loud?
A single global sorted structure becomes a hotspot: every update and every top-N read hits the same place. The fixes are the usual ones, but the narration matters more than the list.
Partition by segment — region, game mode, time window — so each board has its own structure and its own load. Cache the top-N with a short time-to-live so repeated reads do not recompute. The staleness budget you agreed in requirements is what lets you defend the cache: "a few seconds old is within what we said we needed."
When the interviewer pushes on scale, use a three-part script: state the bottleneck, the mitigation, and the new cost you accept. For example: "The global board is a hotspot because every write and read lands in one structure. I'd partition by region so each board scales on its own. The cost is that a global top-100 now needs a merge across partitions, so that read gets more complex." That last clause is what separates a confident answer from a hand-wave. The Data Partitioning System Design Interview: Choosing a Key walks through the same reasoning for partition keys.
How do you handle ties, cheating and score corrections?
Decide the tie rule in requirements, not as a patch later. A workable rule is earliest timestamp wins: if two players share a score, the one who reached it first ranks higher. It is deterministic, it is easy to explain, and it uses a field you already store. The reason to settle it early is that the tie-break field is part of your sort key — changing it later means reordering everything.
Score corrections and deletions are the awkward case. A late-arriving correction has to propagate to the ranking store, which means your write path needs an update and a remove, not just an append. If you batched updates, the correction rides the same pipeline, so you need dedupe and ordering so an old value does not overwrite a newer one.
On cheating, keep it honest and scoped: validating score events and keeping an audit trail are design concerns you can name. Do not promise that any tool or rule eliminates cheating; say how you would detect and correct bad data, and leave the policy to the product side.
What does a strong 35-minute walkthrough sound like, start to finish?
A timed outline keeps you from spending twenty minutes on the data model and rushing the trade-offs.
- 5 minutes — requirements. Ask the checklist questions, write the answers on the board, confirm the ranking window, freshness and tie rule.
- 10 minutes — data model and read/write paths. Name the fields, choose the storage shape, state the dominant query and the cost you accept.
- 10 minutes — scale and trade-offs. Partition by segment, cache the top-N, walk the synchronous-versus-batched table.
- 5 minutes — failure modes. Queue backlog, stale rank, late corrections, a hotspot partition.
- 5 minutes — recap. Name the two trade-offs you made and what you would revisit.
Here is a sample spoken segment for the data model decision, so you can hear the level of detail expected:
"The dominant query is top 100 plus my own rank, so I'll keep scores in a structure sorted by score and then by earliest timestamp. That makes the top 100 a cheap read and gives a deterministic tie rule. The cost is that every score update touches that structure, so I'll batch writes through a queue and accept a few seconds of staleness. If exact rank for every player turns out to be required, I'd add a periodic job that recomputes positions, and that rank would be stale between runs."
That is roughly the density to aim for: one choice, one reason, one cost, one fallback.
Which mistakes sink leaderboard answers most often?
The three common ones:
- Skipping requirements. You design for an imagined scale and the interviewer has a different one in mind.
- Treating rank as free. Exact rank for every player is the expensive part, and pretending otherwise gets caught on the follow-up.
- Going silent while thinking. The interviewer scores your reasoning, and silence hides it.
A weak-then-stronger rewrite of the classic moment. Weak: "I'd use a sorted set." Stronger: "I'd use a sorted set because the dominant query is top-N, and I'd key it by score then timestamp so ties are deterministic. The cost is write amplification on every score update, which I'd handle by batching." Same component, but now it is a decision with a reason and a price.
Run this self-check after a practice session:
- Did I state the three driving decisions in the first five minutes?
- Did I write requirements down and refer back to them?
- Did every choice come with a cost?
- Did I name a fallback when the interviewer pushed?
- Did I recap the trade-offs at the end?
How should you practise this walkthrough before the interview?
Run it three times. First, a timed solo run to get the 35-minute shape into your head. Second, a run where you narrate only the trade-offs and skip the components, to train the habit of saying what each choice costs. Third, a run where a peer interrupts with follow-ups — "what if rank must be exact?", "what if the burst is ten times bigger?" — so you practise extending rather than repeating.
After each run, review where the reasoning got thin. That review, not the diagram, is the skill you are building. If you tend to over-explain, the Stop Rambling Interview: A Live Answering Plan pairs well with this walkthrough. A practice aid such as AI Interview assistant can give you a place to rehearse out loud and notice the gaps, but the reasoning has to be yours.
Before you walk in
The leaderboard question rewards structure over recall: requirements first, then a data model with a stated cost, then an honest scale story. Pick one thing to do next — write the three driving decisions on a card and say them aloud until they come out in under thirty seconds. That single habit carries most of the walkthrough.
Frequently asked questions
Do I need to write code or pseudocode in a leaderboard system design interview?
Usually no. Most interviewers want the data model, the read and write paths, and the trade-offs stated in plain language. If they ask for pseudocode, keep it to the shape of the ranking lookup and the update path, a few lines each, and narrate what each line assumes. Ask whether they want code before spending time on it.
How do I answer if the interviewer asks for exact rank for every player, not just the top 100?
Accept it and name the cost. Exact rank for everyone usually means a periodic job that recomputes positions, so rank is stale between runs, or a structure that supports position lookup on every write, which raises write cost. Say which you would pick given the freshness requirement, and state the staleness or write amplification you are accepting.
What if I don't know the scale numbers — can I ask the interviewer?
Yes, and you should. Offer a concrete estimate and ask them to confirm or correct it. That turns a guess into a shared assumption you can design against, and it gives you something to point back to when you defend a choice later. Interviewers usually prefer a stated assumption over silence.
How is a leaderboard question different from a general ranking or search question?
A leaderboard is narrow: a small set of fields, a dominant top-N read, and a tie rule that must be deterministic. A search ranking problem usually involves relevance scoring over many signals and a much larger, fuzzier result set. On a leaderboard, the interesting decisions are freshness, exact versus approximate rank, and how you batch writes.
Rehearse the walkthrough out loud and review where the reasoning got thin.