ProblemFeeds and search
Top-K and leaderboards
Rank millions of players on a live leaderboard and list what is most popular right now.
The brief
Online game · suggested for Senior
Design leaderboards and trending for an online game
Design the season leaderboard and the trending levels for an online game: every player’s rank from about 300 million match results a day, and the most-played levels from about a billion plays a day.
An online multiplayer game has about 40 million daily players in three regions. Every match ends with points for each player. A season lasts three months, and the season leaderboard ranks every player by their total points; at the end of the season the top 1,000 win prizes. Players see the top 100, their own rank with the 10 players just above and below them, and how they rank among their friends. Players also build and share levels. The game shows the 100 most-played levels in the last hour and in the last 24 hours, refreshed every minute; phones that were offline send their plays when they reconnect. Design the leaderboard and the trending levels: how a result or a play is recorded, where each board is read from, and how both stay right.
Functional requirements
- CoreShow the season’s top 100 players, and any player’s rank with the 10 players just above and below them.
- CoreShow how a player ranks among their friends (up to about 200).
- CoreA finished match updates the player’s season total and rank within about 5 seconds.
- CorePlayers with the same total are ordered by who reached it first.
- CoreShow the 100 most-played levels in the last hour and in the last 24 hours, refreshed every minute; a play sent up to about 10 minutes late still counts in the hour it was played.
- CoreAt the end of the season, produce the final top 1,000 for prizes.
Non-functional requirements
- LatencyBoard and rank views load within about 200 ms p99.
- ConsistencyThe final prize board is exactly right: every match counted once, none lost, and the result can be audited.
- ConsistencyTrending may be about a minute behind and slightly approximate.
- AvailabilityBoards stay fast in the last hour of a season, when views rise about five times.
- AvailabilityEach region keeps showing boards if another region is down.
Scale
- ScaleAbout 40 million daily players, and about 80 million players on this season’s board.
- ScaleAbout 300 million match results a day, about 15,000 a second at peak.
- ScaleAbout 5 million community levels and about a billion plays a day, about 40,000 a second at peak; one viral level can take about 20,000 plays a second.
- ScaleAbout 20,000 board views a second, about 100,000 in the last hour of a season.
- ScaleThree regions; each player plays in their home region.
- ScaleGame servers retry until a result is accepted; every result arrives within about 10 minutes of its match ending.
Nice to mention (below the line)
- Below the lineMatchmaking and the game itself.
- Below the linePaying out prizes.
- Below the lineModerating community levels.
Out of scope
- Out of scopeDetailed cheat detection.
The variant
One fully specified brief, with the level it suits best. You can practise it at any level.
- Online gameSuggested for Senior
An online multiplayer game: a season leaderboard with prizes for about 80 million players, and the most-played community levels, in three regions.
8 steps · 5 must-pass · about 44 min at Senior
What each level is graded on
Online game, step by step. A result at a level needs its must-pass steps answered, and only the steps you answer count. Going up a level adds steps or holds them to a stricter bar.
| Step | Entry level | Mid-level | Your levelSenior | Staff |
|---|---|---|---|---|
| The numbers that shape the design (optional) | Graded | Graded | Graded | Graded |
| Matches, plays and seasons | Graded | Graded | Graded | Graded |
| The board and trending calls | Graded | Graded | Graded | Graded |
| From a match to the board, from a play to trending | Must-pass | Must-passcan block | Must-passcan block | Must-passcan block |
| Where do I stand? | Must-pass | Must-pass | Must-pass | Must-pass |
| Trending this hour | Must-pass | Must-pass | Must-pass | Must-pass |
| The prize board | — | Must-pass | Must-passcan block | Must-passcan block |
| A viral level | — | — | Must-pass | Must-pass |
| Half a billion players, three regions | — | — | — | Must-pass |
| At this level | 6 steps 3 must-pass about 32 min | 7 steps 4 must-pass about 38 min | 8 steps 5 must-pass about 44 min | 9 steps 6 must-pass about 51 min |
Entry level6 steps · 3 must-pass · about 32 min
- The numbers that shape the design (optional)Graded
- Matches, plays and seasonsGraded
- The board and trending callsGraded
- From a match to the board, from a play to trendingMust-pass
- Where do I stand?Must-pass
- Trending this hourMust-pass
Mid-level7 steps · 4 must-pass · about 38 min
- The numbers that shape the design (optional)Graded
- Matches, plays and seasonsGraded
- The board and trending callsGraded
- From a match to the board, from a play to trendingMust-passcan block
- Where do I stand?Must-pass
- Trending this hourMust-pass
- The prize boardMust-pass
SeniorYour level8 steps · 5 must-pass · about 44 min
- The numbers that shape the design (optional)Graded
- Matches, plays and seasonsGraded
- The board and trending callsGraded
- From a match to the board, from a play to trendingMust-passcan block
- Where do I stand?Must-pass
- Trending this hourMust-pass
- The prize boardMust-passcan block
- A viral levelMust-pass
Staff9 steps · 6 must-pass · about 51 min
- The numbers that shape the design (optional)Graded
- Matches, plays and seasonsGraded
- The board and trending callsGraded
- From a match to the board, from a play to trendingMust-passcan block
- Where do I stand?Must-pass
- Trending this hourMust-pass
- The prize boardMust-passcan block
- A viral levelMust-pass
- Half a billion players, three regionsMust-pass
- Must-pass
- a result at that level needs this step answered.
- Can block
- a miss there is a Blocking issue at that level.
Going up a level
- Mid-level
- A miss on “From a match to the board, from a play to trending” can now block the result.Adds “The prize board”, must-pass.
- Senior
- “From a match to the board, from a play to trending” is graded more strictly.A miss on “The prize board” can now block the result.Adds “A viral level”, must-pass.
- Staff
- Adds “Half a billion players, three regions”, must-pass.
Skills this problem practises
Your coach tracks readiness per skill across every problem you practise. Each links to the lesson that teaches it.
- Capacity estimation
- API design
- Idempotency and retries
- Data modelling
- Choosing storage
- Indexing
- Sharding and partitioning
- Queues and async messaging
- Caching
- Failure modes and recovery
- Observability and operations
- Rate limiting and abuse
Worked solution
Try it first: practise a variant, then read the walkthrough and compare it with your own design. Reading it first makes the practice much less useful.
Learn: Design a leaderboard and top-KYour history
Sign in to see your sessions on this problem.