AlgoViz

Design a Multiplayer Game Leaderboard

easy 45 min

Keep 250 million players in order while results arrive all the time, and tell any of them their place in milliseconds.

How to approach it

What this question tests, where it gets hard, and how to spend the time.

Read the question

What this problem tests

  • A structure, not a box

    Can you say why counting a rank is expensive, and which structure makes it cheap?

  • Shared and personal

    Do you separate the list everyone sees from the place only one player sees?

  • Trust

    Who is allowed to say what the score is?

  • Knowing when to stop

    250 million players fit on one machine. Do you notice?

Ask yourselfHere
Who does what?Game servers report results; players read boards
What must never go wrong?An accepted result is never lost, and a fake one is never shown
What is the hardest thing?One player's place among hundreds of millions
What breaks first?Counting rows for a rank, then the number of reads
What am I giving up?A few seconds of freshness

Five questions in order

Spend the 45 minutes

MinutesDoSkip
0 to 5Score rule, boards, ties, freshnessAchievements
5 to 10Writes, reads split in two, memoryBandwidth
10 to 15Result and rank callsProfile fields
15 to 25Version 1 and then growProduct names
25 to 40Rank at scale, ties, trustEvery edge case
40 to 45Failures and recapNew features

Do

  • Say that ranks are counted, not stored
  • Split reads into shared and personal
  • Name the game server as the source
  • Say what the place of player 40 million is worth

Traps

  • A row with a rank column
  • Pushing all rank changes
  • A job that empties the board at midnight
  • Sharding by player hash, then asking for a rank