Design a Public High-Scores Leaderboard

System Design
Medium
Google
58.4K views

Design a system for a video game to maintain a global, real-time leaderboard. Discuss data structures (Redis Sorted Sets) and handling fraudulent scores.

Why Interviewers Ask This

Interviewers ask this to evaluate your ability to design scalable, real-time systems under high concurrency. They specifically test your knowledge of data structures like Redis Sorted Sets for O(log N) operations and your awareness of security risks in gaming ecosystems, such as score manipulation or bot attacks.

How to Answer This Question

1. Clarify requirements: Define scale (users per second), latency needs (real-time vs. eventual consistency), and specific constraints like fraud detection thresholds. 2. High-level architecture: Propose a microservices approach where game servers write scores to an API gateway before hitting the caching layer. 3. Data modeling: Explain why Redis Sorted Sets are ideal here, detailing how they store scores with O(log N) insertion and range queries for top-N retrieval. 4. Fraud prevention: Discuss implementing rate limiting, anomaly detection algorithms (e.g., flagging impossible speed records), and human review queues. 5. Scalability and failure: Address sharding strategies for massive datasets and fallback mechanisms if Redis fails.

Key Points to Cover

  • Explicitly choosing Redis Sorted Sets for their O(log N) complexity and native ordering capabilities
  • Demonstrating a concrete strategy for detecting and preventing score manipulation or botting
  • Addressing consistency models and how to handle potential race conditions during simultaneous updates
  • Proposing a sharding or partitioning strategy to ensure horizontal scalability
  • Considering fallback mechanisms and error handling for distributed system failures

Sample Answer

To design a global, real-time leaderboard, I would start by clarifying that we need sub-second latency for updates and strict integrity against bots. For the core data structure, Redis Sorted Sets are the industry standa…

Common Mistakes to Avoid

  • Ignoring the security aspect entirely and focusing only on the data structure without discussing fraud detection
  • Suggesting a relational database like MySQL for the primary storage, which would struggle with the required write throughput and sorting performance
  • Failing to define the read/write patterns clearly, leading to an inefficient design that doesn't match real-world gaming traffic
  • Overlooking edge cases like tie-breaking rules or what happens when a player submits multiple scores in quick succession

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 190 System Design questionsBrowse all 145 Google questions