Opening Scenario

Your company runs a mobile game with 30 million daily active players. Product just launched weekly tournaments. Each player accumulates points by winning matches. The in-game UI shows a live leaderboard with the player's rank, the top 100 globally, and the nearest 10 players above and below. In the current implementation, every match writes a score to MySQL. The leaderboard endpoint runs SELECT * FROM scores ORDER BY total DESC LIMIT 100 and computes per-player rank with a window function. It worked at 100k players. At 30M players, the query takes 12 seconds. The database is at 90% CPU. The leaderboard is stale by minutes. Ranks jump erratically because reads see partial updates. The product manager wants sub-second rank-on-score-change, exact top 100 globally, approximate rank for the long tail, and tournament reset every Sunday at midnight UTC. Before you redesign, you need to understand what makes leaderboards hard at scale. You also need to know why streaming is the natural fit. Finally, you need to know the canonical Kafka + sorted-set architecture that powers them.

In the full tutorial

  • Question Progression
  • When to Reach for This

Glossary history

Click dotted jargon to save explanations here.