I went straight to Redis sorted sets and they seemed fine with that direction, but I fumbled a bit when they pushed on regional breakdowns.
Start by clarifying requirements: scale (QPS, number of players), latency targets, consistency needs, and regional definitions. Then propose a high-level architecture using a fast in-memory store (e.g., Redis sorted sets) for global and per-region leaderboards, with a write path that updates scores and a read path that serves top-N, rank, and neighbors. Discuss trade-offs around consistency, sharding, and caching.
Pro tip: Emphasize that leaderboards are read-heavy and can tolerate eventual consistency; use Redis sorted sets with periodic snapshots to a durable store, and consider approximate ranking for massive scale to avoid O(log N) updates on every score change.
Ask about number of players, score update frequency, read QPS, latency targets, and consistency requirements. Define what 'region' means and whether leaderboards are per-region or global with regional filters.
Propose a write path: score updates go to a message queue (e.g., Kafka) for buffering and then to a stream processor that updates leaderboards. Read path: API servers query an in-memory data store (e.g., Redis) for top-N, rank, and neighbors.
Use Redis sorted sets for each leaderboard (global and per-region). Score updates use ZADD, top-N uses ZREVRANGE, rank uses ZREVRANK, and neighbors use ZREVRANGE around the player's rank. For durability, periodically snapshot to a database like Cassandra or DynamoDB.
Shard leaderboards by region and possibly by player ID ranges to distribute load. Use consistent hashing to route requests. For global leaderboard, aggregate regional top-N lists or use a separate global sorted set updated asynchronously.
Discuss consistency vs. latency: eventual consistency is acceptable for leaderboards. Consider approximate ranking (e.g., using t-digest) for very large scale. Cache top-N results with short TTL. Handle hot keys by replicating or sharding further.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.