Design a Multiplayer Game Leaderboard
easy 45 minKeep 250 million players in order while results arrive all the time, and tell any of them their place in milliseconds.
Explain your choices
Answer first. Then compare your reasoning.
11 questions 0 got it 0 to review11 not marked
Decisions
| Decision | Choice | Because | Change if |
|---|---|---|---|
| Order | Redis sorted set | Place in about 28 steps | Small board: SQL |
| Owner of scores | PostgreSQL | Rebuild and audit | Very high write rates: a key-value store |
| Consistency | 2 to 5 s | Nobody can tell | Finals: freeze first |
| Friends | Live ZMSCORE up to 500 | Always fresh, nothing stored | Huge lists: compute before |
| Split | By board | A rank stays one command | One board too large: bands |
| Live | Own result only | 2.3M pushes otherwise | A final of ten players |
When they push back
| They say | Answer with |
|---|---|
| "Why keep PostgreSQL?" | "Redis replication is asynchronous. I want to lose a machine without losing a score." |
| "Could DynamoDB or Cassandra do it?" | "They can own scores by key. They do not count a place among others, so I still need an ordered structure." |
| "25 GB in one key?" | "It fits. I worry about the copy after a failure, so I test that time and split before it hurts." |
| "Why not exactly-once?" | "Best score with GT gives the same result twice. For sums I would store the result ID." |
| "Can the CDN hold ranks?" | "One key for each player would almost never be hit twice in ten seconds." |