KatInterview

Design a Multiplayer Game Ranking System

System DesignModel answer
HardModel answerSystem Designleaderboardhigh-throughputcaching

Last updated

Build a backend that tracks player scores, displays global and friend rankings, shows a player's position with nearby competitors, and supports multiple time periods.

You're building the backend infrastructure for a competitive multiplayer game's ranking system.

Your system must handle:

  1. Score submission: Accept and process score updates from active game sessions. Expect significant write traffic from thousands of concurrent players.

  2. Global rankings: Retrieve the top-performing players (configurable limit, typically 10–100 entries) sorted by score.

  3. Friend rankings: For any given player, show how they and their friends compare, sorted by performance.

  4. Contextual positioning: Given a player, return their current rank plus a window of players immediately above and below them in the standings.

  5. Time-based views: Support separate rankings for different periods—today, this week, the current competitive season, and lifetime statistics.

  6. Performance requirements: Read queries for ranking displays must complete quickly even as the player population and submission rate grow large.

Your task is to design this system end-to-end. Cover the requirements (functional and scale assumptions), API contracts, storage architecture, how you'll maintain sorted rankings efficiently, handling ties between equal scores, read optimization strategies, horizontal scaling, consistency guarantees, protecting against fraudulent submissions, and operational considerations like rebuilds and archival.

Explain your reasoning for key decisions and discuss trade-offs where alternatives exist.

Hints

Hint 1

Separate durable storage of score events from the structures you use for fast rank queries—they serve different purposes

Hint 2

In-memory sorted data structures can handle millions of ranking operations per second; consider what happens when a single ranking grows beyond one machine's capacity

Hint 3

Computing friend rankings on every request is feasible when friend lists are small; compare fan-out-on-write versus fan-out-on-read