Layer 3 · Go deeper · 11 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How much memory do all the boards need?
How many writes a second can one sorted set take?
What does a live top 10 for 2 million viewers cost?
Build-up · 6 steps
Build the high-level design
One functional requirement at a time, ending with a leaderboard that works for one region at the evening peak.
Step 1 of 6
Game servers submit scores
The phone never reports its own score; the game server that refereed the match does. The score API validates it, writes the board entry with a conditional update, then ZADDs it into a sorted set.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“Fifty million players and 12k screen views a second, each asking “what’s my rank?”. How do you answer it?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“p_2238 and p_8812 both have 48,250, and p_2238 got there first. Whoever got there first should rank higher. How?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“One season board, 50 million members, and a 200k-writes-a-second tournament burst. One Redis primary takes about 50k. How do you split it?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Redis replication is asynchronous, so a failover can lose acknowledged writes. How do you make sure an accepted score is never lost?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Daily boards reset at midnight IST, with 20 million members on today’s board and matches still running. How do you roll over?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“On an IPL final night, 2 million people watch one contest’s live top 10. How do you keep every screen current?”
Your move. Pick an approach:
Build-up · 6 steps
Follow one score, then one screen view
Scores flow through a log into a database and sharded sorted sets; reads come from replicas and caches; live viewers get one delta a second.
Step 1 of 6
Submit
A game server posts the result. The score API authenticates it, checks per-match limits, appends it to score-events with acks=all and returns 202 within milliseconds.