Lesson 11 of 15
35. Design a Leaderboard (Top-K)

35.10 What would you say in the last five minutes?

3 min read+10 XP

Step 6: Wrap-up (5 minutes)

  • Bottlenecks: write bursts from popular players (batching, sharding, pipelining) and refresh traffic (cached top 100, cached per-user rank until the next batch).
  • Single points of failure: Redis shards (replicas; rebuildable from teams and player points), the batch scheduler (run two with a lock or leader, Chapter 17).
  • Correctness for money: the final job recomputes from the verified event list, applies tie and prize rules, and writes an audited table; live ranks are informational.
  • Next with more time: friends' leaderboards (a small sorted set per group, or rank lookups for a list of friends), private leagues with instant updates, and historical leaderboards stored cheaply after the match.

Memory code: "Live is fast and roughly right; final is slow and exactly right."