Amazon DynamoDB (50 Qs)•Part 3: Advanced Architecture, Scale & Internals (Senior / Lead)
How do you handle leaderboard / rank queries efficiently in DynamoDB?
senior LevelSystem DesignDynamoDB
In Simple Words:
- DynamoDB cannot compute dynamic ranking (like SQL
RANK() OVER) across millions of items efficiently. - Best approach: Store top scores in high-tier buckets (e.g.
PK = "SCORE_BUCKET#900_1000"), or offload live real-time leaderboards to Redis Sorted Sets (ZADD,ZREVRANK), using DynamoDB as the persistent backing store.