Design a Multiplayer Game Leaderboard
easy 45 minKeep 250 million players in order while results arrive all the time, and tell any of them their place in milliseconds.
Agree on the scope
Ask what changes the design, then commit to a short list.
Clarifying requirements
Interviewer
Design a leaderboard for a multiplayer game.
You
First, how is a score made, and who sends it?
- Best score, sum of points, or a rating?
- How many players a day, and how often do they look?
- Which boards: global, region, mode, friends?
- Which periods?
- How old may a place be?
- Are there prizes?
Interviewer
Best score in the week. 100 million players a day, five matches each, about 50 looks. Global, region, mode and friends. Weekly and all time. A few seconds old is fine. Small prizes each week.
You
Then results come from our game servers and I keep every one. I will build the weekly global board first, then ranks, then friends. Guilds and replays are out of scope.
Functional requirements
| Requirement | Priority |
|---|---|
| Accept and update scores as matches end | Must have |
| Top N of any board | Must have |
| My rank, neighbours and percentile | Must have |
| Global, regional, mode and friends boards | Must have |
| Check scores for cheating | Must have |
| Daily, weekly, season and all-time boards | Should have |
| Tell a player about a new place | Should have |
| History of a player's places | Nice to have |
Quality targets
| Quality | Target | Why |
|---|---|---|
| Scale | 100M players a day | Five matches and 50 looks each |
| Read latency | p99 under 50 ms at our service | A board opens inside the game |
| Accept a result | p99 under 100 ms | The match screen is waiting |
| Freshness | 2 to 5 s on boards, 10 s more on the top list | Nobody notices |
| Durability | No accepted result lost | It may decide a prize |
| Availability | 99.9%, and the game runs without us | A board is not the match |