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.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

Store the order, count the place, cache what is shared.

A row of sunflowers by height. A new flower slips into its place, a photo at the gate shows the tallest three, signs count each height, and every week has its own bed.

Cheat sheet

Results
5,800/s, 17,400 peak
Looks
57,900/s, 174,000 peak
Weekly board
25 GB
Place
About 28 steps
Top list
CDN, 10 s, 2,000 fills/s
Tie
Score x 2^20 + time left
Friends
ZMSCORE, 500
Reset
New key
Cheating
Server signs, odd scores wait

Spot it when you see

  • Where am I among many?
  • Top N by a number.
  • Scores for a period.

Tricks that stick

  • Shared or personal? That decides the cache.
  • GT makes repeats harmless.
  • 33 + 20 = 53.

Do not forget

  • A rank column.
  • Pushing all moves.
  • Trusting the app.
  • A midnight delete.
  • Milliseconds in the packed score.
  • Sharding by player and asking for a rank.