Design an Online Game Leaderboard
Company: Meta
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Technical Screen
##### Question
Design the backend system for an online game's leaderboard.
The system should support:
1. **Recording and updating player scores** from game sessions, with high write volume from many concurrent players.
2. **A global leaderboard** showing the top N players by score (for example, the top 10 or top 100).
3. **A friends leaderboard** showing the top players among a given user's friends.
4. **A player's own rank** plus the nearby players around that rank (an "around me" view).
5. **Multiple leaderboard windows** such as daily, weekly, seasonal, and all-time rankings.
6. **Low-latency reads** for leaderboard pages even at very large scale.
Walk through the functional and non-functional requirements, the API design, the data model, storage choices, the ranking strategy (including tie-breaking), caching, the scaling approach, consistency trade-offs, anti-cheat/validation, and operational concerns. Explain how you keep the global, friends, windowed, and rank/nearby queries efficient when the player base and write volume are large.
Quick Answer: A Meta software-engineer system-design screen: design the backend for an online game leaderboard supporting score recording, a global top-N board, a friends board, a player's rank and nearby players, and daily/weekly/seasonal/all-time windows at high write volume and low read latency. The model answer separates a durable score event log from an in-memory sorted ranking store, computes the friends board on read, and covers tie-breaking, caching, sharding, consistency trade-offs, anti-cheat, and rebuilds.