Quick revision
The short answer
One DynamoDB item has one partition key, and one partition key is limited to roughly 1,000 writes per second, so 50,000 updates per second to one item can never work. We redesign so writes spread out: per-player score items keyed by event and player, write sharding over sub-keys like event_id#0 to event_id#99 where a shared counter is needed, and rankings computed in a Redis sorted set or by a periodic job that writes a combined top-N item. DynamoDB keeps the durable scores, and reads of the hot top-N item are served from a cache or DAX.
What to remember
In this answer, we saw that a single item maps to a single partition with a limit around 1,000 writes per second, so 50,000 updates to one item must throttle. We moved scores into per-player items, used write sharding over 100 sub-keys for shared counters with an aggregation job, computed rankings in a Redis sorted set with DynamoDB as the durable store, batched updates at the game servers, and cached the hot top-N result with a short-lived cache or DAX.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
One DynamoDB item has one partition key, and one partition key is limited to roughly 1,000 writes per second, so 50,000 updates per second to one item can never work. We redesign so writes spread out: per-player score items keyed by event and player, write sharding over sub-keys like event_id#0 to event_id#99 where a shared counter is needed, and rankings computed in a Redis sorted set or by a periodic job that writes a combined top-N item. DynamoDB keeps the durable scores, and reads of the hot top-N item are served from a cache or DAX.
Why this question is asked
Live events produce the most extreme hot keys we meet: everyone plays at the same moment and everyone looks at the same leaderboard. A design that stores the whole leaderboard in one item is natural for a prototype and collapses in production. Interviewers ask this to see whether we know the per-partition limit, the write sharding pattern and when to bring in a purpose-built tool for ranking. In this answer, we will see why the current design throttles, move scores into per-player items, apply write sharding to shared counters, use Redis for ranking, and handle the read side.
1Why One Item Cannot Take 50,000 Writes per Second
In the current design every score update is an UpdateItem on the item with partition key event_id. DynamoDB hashes that key to one partition, and one partition accepts about 1,000 write units per second (check the current limits). An update to an item up to 1 KB costs one write unit, and a leaderboard item holding many players is far larger, so each update costs several units. So the real ceiling is well under 1,000 updates per second, and the demand is 50,000.
Adding table capacity or switching to on-demand does not help, because the limit is per partition, and DynamoDB cannot split a single item across partitions. There is also a size problem: an item is limited to 400 KB, so a single item cannot even hold scores for a large event. The design has to change.
2Writing Per-Player Scores Instead of One Item
The first step is to stop writing to one shared item. Each player's score becomes its own item, keyed by event and player. A player usually updates only their own score, so 50,000 updates per second spread across tens of thousands of different partition keys, and the hash distributes them evenly.
The catch is reading: 'top 10 for the event' now has no single key to query. A GSI with partition key event_id and sort key score would recreate the hot key inside the index, and a hot GSI throttles writes on the base table. So ranking needs a different structure.
3Write Sharding for Shared Counters
When many writers really must update one logical value, such as the total points scored in the event or a per-team tally, we use write sharding. Instead of one key we use N sub-keys, event_id#0 to event_id#99, and each write picks one at random or by hashing the player id. With 100 shards, 50,000 writes per second become about 500 per shard, comfortably under the limit.
Reading the total then means reading all 100 shards and adding them up, which is 100 small GetItems or one BatchGetItem per 100 keys. That is fine for a value read occasionally. For a value read constantly, a scheduled job reads the shards every second or so and writes the sum into one combined item that clients read. Hashing by player id instead of random choice keeps one player's updates on one shard, which helps when we need per-player ordering.
- Game serversbatch each player's updates every 100 ms
- Redis sorted set per eventZINCRBY for scores, ZREVRANGE for top 10
- DynamoDB Scores tableone item per event and player, the durable record
- Sharded totalsEVENT#finals#0..99 for shared counters
- Top-N snapshot itemrewritten every second, cached for readers
5 layers, from the top down. Step through them one at a time.
Rankings live in Redis; DynamoDB holds the durable, evenly spread scores.
4Computing Rankings in a Redis Sorted Set
Ranking is exactly what a Redis sorted set is built for. It stores members with numeric scores, kept ordered, and both updating a score and reading the top N take logarithmic time. A single Redis node handles well over 50,000 simple commands per second.
DynamoDB stays the durable source of truth. The game service writes each update to both, or writes to DynamoDB and lets a DynamoDB Streams consumer apply it to Redis. If Redis is lost, we rebuild the sorted set from the Scores table. We can also cut write volume before it reaches either store by batching: a game server adds up a player's points for 100 ms and sends one update, which often reduces 50,000 updates per second to a fraction of that.
5Serving the Read Side
Thousands of viewers polling the top 10 make that single result a read hot spot. Whether it comes from Redis or from a top-N snapshot item in DynamoDB, we cache it: a one-second cache in the API layer, a CDN for a public leaderboard, or DynamoDB Accelerator (DAX), an in-memory cache in front of DynamoDB, for the snapshot item. A leaderboard that is one second old is perfectly acceptable to players, and it turns thousands of reads per second into one.
6Follow-up questions
How do we choose the number of shards?
Divide the peak writes by a safe per-shard rate, about half the partition limit. At 50,000 writes per second and 500 per shard we need 100 shards. More shards cost more reads when aggregating, so we size for the peak with headroom, not far beyond it.
Why not put the leaderboard in a GSI sorted by score?
Because every item would share the GSI partition key event_id, so the index partition becomes the hot key. A throttled GSI also throttles writes on the base table. GSIs are great for spreading keys, not for one global ranking.
What if Redis and DynamoDB disagree after a failure?
DynamoDB is the source of truth, so we rebuild or reconcile the sorted set from the Scores table. For an event leaderboard, a periodic reconciliation job is usually enough.
7Conclusion
In this answer, we saw that a single item maps to a single partition with a limit around 1,000 writes per second, so 50,000 updates to one item must throttle. We moved scores into per-player items, used write sharding over 100 sub-keys for shared counters with an aggregation job, computed rankings in a Redis sorted set with DynamoDB as the durable store, batched updates at the game servers, and cached the hot top-N result with a short-lived cache or DAX.
Open with
The design throttles because one item is one partition key, and one partition key gets roughly a thousand write units per second at most, while we need fifty thousand updates per second, and the item is large so each update costs several units.
Then, if they want more
More table capacity or on-demand cannot fix that, and the 400 KB item limit is a problem too. I would split it up. Each player's score becomes its own item, keyed by event and player id, updated with an atomic ADD, so the writes spread over many partition keys.
For anything that really is shared, like event totals, I would use write sharding: sub-keys event_id#0 to event_id#99, chosen randomly or by player hash, so each shard takes about 500 writes per second, and a periodic job sums the shards into one combined item that clients read.
For the ranking itself I would use a Redis sorted set, ZINCRBY on each update and ZREVRANGE for the top ten, with DynamoDB as the durable record that can rebuild Redis. I would also batch updates in the game servers, say every 100 milliseconds per player, to cut the volume.
Finally the top-N result is a read hot spot, so I would cache it for a second in the API, or use DAX in front of the snapshot item.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Cassandra documentation, Amazon DynamoDB developer guide
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A leaderboard for a live game event writes 50,000 score updates per second to one...": https://scrivio-interview-library.netlify.app/databases/cassandra-and-dynamodb/9b78310d98/