Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Real-Time Category Leaderboard

Design category-partitioned leaderboards that ingest scores idempotently and publish fresh rankings under skewed load.

Problem statement

For this exercise, assume a competitive application accepts immutable score events for users and exposes a separate leaderboard for each category. A score event contains a globally unique event ID, category ID, user ID, non-negative score delta, and occurrence time.

Users can view the top 100 for a category, request their own rank with nearby users, and subscribe to real-time top-list changes. Each accepted event must affect a user's category total exactly once. Rank entries are ordered by total score descending, then by the time the user first reached that total, then by user ID.

An accepted score should become visible in ranking reads and live updates within two seconds at p95; a response identifies the ranking version it represents. Social graphs, prizes, anti-cheat adjudication, score editing, and cross-category leaderboards are out of scope.

A geographic region may serve as a category in this model. Compare SQL and NoSQL choices and explain the behavior of score acceptance and ranking reads during a network partition.

What to build

  1. Producers can submit an idempotent score event for one user and category.
  2. Users can retrieve the top 100 ranked users for a category with scores, positions, and a ranking version.
  3. Users can retrieve one user's rank and a small window of nearby users within a category.
  4. Connected users can subscribe to category top-list changes and recover a current snapshot after reconnecting or missing updates.

At scale

  • Assume 50 million users across 100,000 categories, with the hottest one percent of categories receiving 80 percent of traffic.
  • Assume peaks of 100,000 score events and 1 million leaderboard reads per second across all categories.
  • Target 200 ms p95 for top-list and user-rank reads and two seconds p95 from accepted score event to ranking and live-update visibility.
  • Score-event delivery and stream processing may occur more than once; accepted totals are durable, and derived ranking state must be rebuildable from durable score records and checkpoints.