KatInterview

Design a Real-Time Gaming Leaderboard Engine

System DesignModel answer
MediumModel answerSystem Designsystem-designrediscaching

Last updated

Architect a high-throughput, low-latency leaderboard platform handling tens of millions of active players and millions of concurrent score updates.

Architect a scalable backend system for a competitive mobile gaming application with 50 million Daily Active Users (DAU). The platform must handle continuous high-frequency score modifications while maintaining accurate global rankings.

Requirements

Functional Requirements

  1. updateScore(userId, score): Record a new score achieved by a user.
  2. getTopPlayers(k): Return the list of top $k$ ranked players globally (where $k \le 1000$).
  3. getRank(userId): Return the current global rank and score for a specific player.
  4. getNearbyPlayers(userId, k): Return the $k$ players positioned directly above and below a given user in rank.

Non-Functional Requirements

  • High Write Throughput: The system must sustain peak workloads of 1–2 million score updates per second globally.
  • Low Latency Reads: Top-tier leaderboards and rank lookups must respond within tens of milliseconds (99th percentile under 50ms).
  • Scalability & Availability: The architecture must scale linearly and remain highly available.
  • Data Integrity & Real-Time Accuracy: Minor rank propagation delays (up to a few seconds) are acceptable (eventual consistency), but data must be durable against crashes.

Key Deliverables

  • Data Model & Storage Engine Selection: Select appropriate data structures and persistent storage solutions, detailing trade-offs.
  • High-Level System Architecture: Diagram/outline component interactions from ingestion to serving reads.
  • Sharding & Partitioning Strategy: Explain how data is distributed across nodes to solve both compute and write bottlenecks for global ranks.
  • API Specification: Define endpoints, payloads, and idempotency guarantees.

Hints

Hint 1

Calculate total memory footprint vs. network/CPU bandwidth. The core bottleneck is often write IOPS and network fan-out, not memory storage.

Hint 2

Consider how to handle global rank calculations across multiple partitioned nodes without requiring expensive cross-node synchronization.

Hint 3

Distinguish between the fast in-memory ranking index and the durable persistent storage of truth.