HARDDistributed Systems
Design a Real-time Gaming Leaderboard
Design a real-time leaderboard system for a multiplayer online game with millions of concurrent players. The system should handle score updates, rankings, and friend comparisons.
Estimated Time: 45 minutes
#Redis#Sorted Sets#Real-time#Gaming
Solution Overview
Use Redis sorted sets for O(log N) ranking operations. Implement sharding by game/region, with periodic aggregation for global leaderboards.
Hints to Get Started
1
Consider write vs read ratio
2
Redis sorted sets provide O(log N) operations
3
Think about real-time friend rankings
Scaling
Shard by game_id or region, use read replicas for queries
Data Flow
Score update -> Validation -> Redis ZADD -> Pub/Sub for real-time updates
Components
- •Redis Cluster for sorted sets
- •Game servers for score submission
- •Aggregation service for global rankings
- •CDN for read-heavy operations