Real-time Leaderboard
Rank millions of players by score and serve top-N and my-rank queries in milliseconds.
Easy35 minRedis sorted setsShardingRanking
A game leaderboard ranks players by score and answers "who is in the top 100?" and "what is my rank?" instantly, even with millions of players updating scores constantly. The heart of the problem is ranking, which sorted data structures make cheap and relational queries make expensive.
Clarify requirements
Functional
- Update a player's score when a match ends (increment or set best score).
- Get the top N players (N ≤ 100).
- Get a player's rank and score, plus the players just above and below.
- Leaderboards per game and per season (monthly reset); optionally friends-only and regional boards.
Non-functional
- 50M monthly active players, 10M daily active.
- Score updates visible in the leaderboard within about a second.
- Reads p99 < 50 ms.
- Scores must not be lost; leaderboard can be rebuilt from durable data.
- Ties broken by who reached the score first.
Try it first
Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.
35:00
Defend it out loud
The AI interviewer will probe your design for Real-time Leaderboard and score it.