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.

Grow the design

Start with the smallest system that works. Change it only when something breaks.

Six versions

Version 1: One service, one database

Forced by: The feature: keep scores and show the top.

Our systemPlayersGame serverOne servicePostgreSQLbest scores
What changes
A table of best scores with an index on board and score. The top 100 reads 100 index entries. A rank counts the rows ahead.
What it costs
One machine to run.
What breaks next
A rank in the middle of 250 million counts 125 million entries.

Say: "With ten thousand players I would stop here."

Where am I?

Why each part is there

PartJobWithout it
Result logKeeps results until appliedA Redis outage loses scores
PostgreSQLOwns scores and historyA lost board cannot be rebuilt
Redis shardsOrder and placeRanks count rows
CDNAnswers shared lists139,000 reads a second
Profile cacheNames for IDsStale names inside the board
Live topicOwn result onlyPlayers poll after a match