Learning on Web Dev Open is free for all.

Interview Prep · System DesignDesign a global leaderboard
← System Design

Design a global leaderboard

Medium40 minFree, no account

Top-100 is easy. "What is my rank" out of fifty million is the question.


The question

Design the leaderboard for a game with 50 million players: a global top 100, and every player can see their own rank.

Scores update constantly during play.

Functional
  • Top N globally, and within a friends list.
  • A player can see their own rank and the players immediately around them.
  • Daily, weekly and all-time boards.
Non-functional
  • 50M players, 1M score updates/sec at peak.
  • Top-100 read is effectively free and constant.
  • A player's own rank may be a few seconds stale.
40:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Named sorted sets with the right operations and complexities20
  • Found the hot-key write problem and reduced the write rate at source25
  • Sharded and confronted what sharding costs the rank query20
  • Questioned whether rank must be exact and gave an approximate scheme25
  • Handled time windows with expiry rather than recomputation10

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only