Design a Leaderboard
MediumSystem design · Ranking
Design a leaderboard for a game with 50M ranked players and up to 200K score updates/s during events. Clients read the top N, their own rank, and the players around them, on daily, weekly and all-time boards, plus friend boards. Cover the sorted data structure, sharding that keeps ranks exact, ties, period rollover, caching the top page, cheating, and when approximate rank is acceptable.
Requirements
- Keep only each player's best score per board; ties are broken deterministically
- Top N and a player's rank are served in logarithmic time or better, and writes are sharded to reach 200K/s
- Support multiple periods with atomic rollover and friend or regional boards
- Scores are validated server side and a cheater can be removed with ranks recomputed