Loading section...
Design a Real-Time Leaderboard System
Concepts: pyLeaderboard, pyRedisSortedSet, pySegmentTree
The real-time leaderboard is the canonical system design problem that tests heap knowledge at the staff level. Top-K users by score with frequent score updates. Millions of users. Millisecond read latency. You need to support: update score (frequent), get top-K users (read-heavy), get a user's rank (occasional). This question is deliberately open-ended because the right answer depends on scale and consistency requirements. Three main options: in-memory heap, Redis sorted set, segment tree. Each has a clear use case. Option 1: In-Memory Python Heap (Single Machine) Option 2: Redis Sorted Set (Distributed, Production) Comparison: When to Use Each The segment tree option is worth mentioning when the interviewer probes for alternatives. If the score range is bounded (e.g., 0 to 1,000,000), a s