Design a Real-Time Leaderboard
A case study of a gaming leaderboard built on Redis sorted sets, covering rank queries, top-K reads, sharding past one node and daily or weekly boards.
Requirements
A leaderboard ranks players by score and answers questions like "who is in the top 10?" and "what is my rank?" while scores keep changing.
Functional:
- Submit or increase a player's score.
- Get the top K players (K is often 10 to 100).
- Get one player's rank and score.
- Get the players just above and below me (my neighbourhood).
- Separate boards: daily, weekly, all-time, per game or region.
Non-functional:
- Updates appear on the board within about a second.
- Reads are fast (under 50 ms) even with 100 million players.
- Rank must be consistent: two different players never share a rank unless the rules say ties are allowed.
- Scores are never lost; the board can always be rebuilt.
1 of 11