
Building a Leaderboard That Can Handle 5,000 Score Updates Per Second with DynamoDB
Build a high-throughput leaderboard with Amazon DynamoDB using write sharding to handle thousands of score updates per second.Explore Top-N rankings, participant rank, neighboring players, and cross-leaderboard profiles through purpose-built access patterns.Learn how thoughtful DynamoDB data modeling helps balance scalable writes, efficient reads, and unpredictable live-event traffic.
A leaderboard sounds simple.
Someone plays a game → gets a score → we save it → we sort the scores → we show the winners.
Simple, right?
Now imagine a live cricket match.
Thousands of fans are predicting the next ball, answering trivia questions, or competing in fantasy challenges. Every few seconds, thousands of people are submitting their scores.
Suddenly, our simple leaderboard has a problem.
What happens when 5,000 people try to update the same leaderboard at the same time?
That was the question I explored in DynamoDB Developer Challenge #2.
The challenge was to design a leaderboard platform that could support more than 1,000 score updates every second for a single leaderboard, while still answering questions such as:
- Who are the top 10 players?
- What is my score?
- What is my rank?
- Who is immediately above me?
- Which other leaderboards am I participating in?
The interesting part wasn't storing the scores.
The interesting part was making the leaderboard scale.
Figure 1: The leaderboard platform used for the challenge

I built a simple interface around the DynamoDB design so I could test the different access patterns-creating leaderboards, submitting scores, viewing Top-N rankings, looking up participants, and exploring participant profiles.
Let's Start With the Simplest Design
Imagine we create a DynamoDB table and decide:
"I'll keep all scores for a leaderboard together."
For example:
Leaderboard: BestPredictionStreakPlayer A → 9500Player B → 9200Player C → 8900Player D → 8500...In DynamoDB, we might make the leaderboard name the partition key:
PK = BestPredictionStreakAt first, this looks like a great idea.
Everything belonging to the same leaderboard is together.
But now imagine that a popular match starts.
5,000 fans ↓5,000 score updates ↓BestPredictionStreakAll those requests are trying to use the same partition key.
That's where we run into trouble.
The leaderboard has become a hot partition.
What Is a Hot Partition?
If you're new to DynamoDB, think of a partition like a storage bucket.
DynamoDB automatically distributes your data across many physical partitions behind the scenes.
That's one of the reasons DynamoDB can scale so well.
But there's an important rule:
If too much traffic is concentrated on one partition key, that particular area can become overloaded.
So although the table as a whole might have plenty of capacity, one heavily used partition key can still become the bottleneck.
Our original design effectively says:
DynamoDB | ↓ BestPredictionStreak | ┌────────────┼────────────┐ ↓ ↓ ↓ 1000 1000 1000 requests requests requestsThat's not what we want.
We need to spread the traffic.
The Idea: Split the Leaderboard
Instead of treating one leaderboard as one bucket, what if we split it into smaller buckets?
For example:
BestPredictionStreak
↓
┌─────────────┐│ Shard 0 │├─────────────┤│ Shard 1 │├─────────────┤│ Shard 2 │├─────────────┤│ Shard 3 │├─────────────┤│ Shard 4 │├─────────────┤│ Shard 5 │├─────────────┤│ Shard 6 │├─────────────┤│ Shard 7 │└─────────────┘Now our partition key becomes:
leaderboardName + shardIdSo instead of:
BestPredictionStreakwe have:
BestPredictionStreak#0BestPredictionStreak#1BestPredictionStreak#2...BestPredictionStreak#7Now the 5,000 writes don't all have to hit the same place.
They can be distributed across the eight shards.
How Do We Decide Which Shard Gets a Player?
This is where I initially found the problem interesting.
We could randomly choose a shard.
But then we have another problem.
Suppose Vijay's score was stored in Shard 3.
Later, Vijay opens the leaderboard.
How do we know where to find Vijay?
We could search every shard.
That works, but it's inefficient.
So instead, we make the decision deterministic.
We calculate the shard from the participant ID:
hash(participantId) % shardCountDon't worry if that looks complicated.
The idea is simply:
Give the same player the same bucket every time.
For example:
Vijay ↓calculate hash ↓Shard 3Next time:
Vijay ↓calculate hash ↓Shard 3Always the same.
This gives us two benefits:
Benefit 1: Scores are distributed across shards.
Benefit 2: We can quickly find a particular player's score.
The reference design uses this deterministic approach specifically to avoid having to search every shard for an individual participant.
Figure 2: Submitting a score to the live-match leaderboard

Here,thunder-boltsubmits a score of 5,500 to thelive-matchleaderboard. The participant ID is used to deterministically determine which shard receives the score.
How Many Shards Do We Need?
We don't want every leaderboard to have eight shards.
A small community leaderboard might receive only a few updates per minute.
Creating lots of shards for it would be unnecessary.
So the number of shards is based on expected traffic.

Figure 3: Creating a leaderboard based on expected peak write traffic
In the application, I don't have to manually decide how many shards to create. I provide the expected peak write rate, and the application calculates the required shard count. In this example, a leaderboard configured for 2,100 peak writes/sec was created with 3 shards.
The design uses:
Shard count =ceil(expected peak writes per second / 700)Why 700?
The goal isn't to design right at the partition throughput ceiling. We use 700 writes/sec as a planning target per shard, leaving headroom for uneven traffic distribution and additional write activity such as index updates.
For example:
| Expected peak writes/sec | Calculation | Shards | Target writes/shard || -----------------------: | ----------------: | -----: | ------------------: || 100 | ceil(100 / 700) | **1** | 100 || 700 | ceil(700 / 700) | **1** | 700 || 1,000 | ceil(1,000 / 700) | **2** | ~500 || 2,100 | ceil(2,100 / 700) | **3** | ~700 || 5,000 | ceil(5,000 / 700) | **8** | ~625 |
Expected peak writes = 2,100/sec
2,100 ÷ 700 = 3
Therefore:3 shardsThe reference design intentionally targets 700 writes/sec per shard to provide headroom rather than designing directly against the partition ceiling.
But Now We Have a New Problem
We've solved the write problem.
But we've created a read problem.
Think about our leaderboard again:
BestPredictionStreak
Shard 0 → playersShard 1 → playersShard 2 → players...Shard 7 → playersNow someone asks:
"Who are the top 10 players?"
The top 10 players could be spread across all eight shards.
DynamoDB can't simply say:
"Give me the top 10 across these eight partitions."
So we need another idea.
Enter: Scatter and Gather
The application asks every shard for its best players.
For example:
Top 10 ↓ ┌─────────┼─────────┐ ↓ ↓ ↓ Shard 0 Shard 1 Shard 2 ... ↓ ↓ ↓ Top 10 Top 10 Top 10 ↓ ↓ ↓ └─────────┼─────────┘ ↓ Combine results ↓ Sort ↓ Top 10This is called scatter-gather.

Figure 4: Top-N ranking retrieved from the distributed leaderboard
Here, I requested the top 7 participants from thelive-matchleaderboard. Behind the scenes, the application queries the leaderboard's shards, gathers the best candidates from each shard, and merges them to produce the global ranking.
Scatter
Send the request to all the shards.
Gather
Bring the results back together.
Suppose we have eight shards and want the top 10.
We ask each shard for its top 10:
8 shards × 10 players ↓80 candidates ↓sort 80 players ↓return best 10Notice something important.
We don't need to read every player.
Even if the leaderboard has 10 million players, we're only collecting a small number of candidates from each shard.
That's what makes the approach practical.
The reference design uses exactly this top-N optimization: query each shard for its local top N and merge those candidates instead of reading the entire leaderboard.
What About My Own Rank?
Now let's ask a different question:
"I'm Vijay. What's my score and rank?"
Finding my score is easy.
We calculate my shard:
Vijay ↓hash(Vijay) ↓Shard 3Then DynamoDB can directly find my record.
But rank is different.
Suppose my score is:
8,420To calculate my rank, we need to know:
How many players have a score higher than 8,420?
Those players could be anywhere.
So the application asks each shard:
Shard 0 → How many scores are above 8,420?Shard 1 → How many?Shard 2 → How many?...Shard 7 → How many?Then:
Shard 0 → 12Shard 1 → 8Shard 2 → 15...Add them together.
If 100 players have a higher score:
Rank = 100 + 1 = 101This is more expensive than finding the score.
And that's okay.
Why?
Because we deliberately chose to make writes simple and distributed, while allowing ranking reads to do more work.
The reference design is transparent about this trade-off and identifies exact rank as the most expensive read in the design.

#1 neo-striker 5,100#2 quantum-fox 4,600#3 player-ace 4,200#4 shadow-wolf 3,800#5 dark-phoenix 3,200#6 blaze-runner 2,900#7 storm-rider 1,750Figure 5: Participant lookup showing score, rank, and neighboring players
The lookup view brings several access patterns together. Forshadow-wolf, the application returns the current score, calculates the participant's global rank, and retrieves the players immediately above and below them.
Who Is Immediately Above Me?
Now imagine the leaderboard says:
99 Arun 8,450100 Priya 8,440101 Vijay 8,420102 Rahul 8,410103 Karthik 8,400I want to see:
Who is just above me and just below me?
Again, the answer could be spread across multiple shards.
So we retrieve candidates around my score from the shards, combine them, sort them, and identify my neighbors.
Conceptually:
My Score 8420 ↓ ┌──────┴──────┐ ↓ ↓ Higher scores Lower scores ↓ ↓ Candidates Candidates └──────┬──────┘ ↓ Combine ↓ Find neighborsThis is another example of the same pattern:
Spread the writes → gather the information when we read.
What About All My Leaderboards?
Now imagine I participate in:
- Prediction Streak
- Trivia
- Lineup Builder
- Match Predictor
I want my profile to show all of them.
This is a completely different question from:
"Who is winning this leaderboard?"
So I created a different access path using a Global Secondary Index (GSI).
The GSI is organized around the participant:
Participant ID ↓ Leaderboard ↓ ScoreNow the application can ask:
"Show me everything Vijay is participating in."
And get:
Prediction Streak 9,820Trivia 7,420Lineup Builder 6,850Match Predictor 5,200
Figure 6: Cross-leaderboard profile using a participant-based access pattern
This is a good example of DynamoDB's approach to data modeling:
One table can support multiple ways of asking questions about the data.
User │ ▼ Submit a score │ ▼ Calculate shard │ ▼ DynamoDB Shard │ │ ┌──────────┼──────────┐ │ │ │ ▼ ▼ ▼ Shard 0 Shard 1 Shard 2 ... │ │ │ └──────────┼──────────┘ │ ▼ Scatter-Gather │ ▼ Global Ranking
Architectural Diagram

Sequential Diagram

What I Learned
The biggest lesson from this challenge wasn't about hashing.
It wasn't about shards.
It wasn't even about DynamoDB.
It was about starting with the questions the application needs to answer.
Before designing the table, I wrote down:
Who are the top players?What is my score?What is my rank?Who is around me?Which leaderboards do I participate in?Then I designed the database around those questions.
That changed the way I looked at DynamoDB.
Instead of asking:
"How should I store a leaderboard?"
I started asking:
"How will my application read this data?"
And that is a much better question.
Final Thoughts
A leaderboard looks simple from the outside.
Behind the scenes, it can become a surprisingly challenging distributed system.
The final design uses:
Write sharding to distribute high-volume score submissions.
Deterministic shard assignment to find individual participants efficiently.
Scatter-gather reads to reconstruct global rankings.
A participant-oriented GSI to build cross-leaderboard profiles.
Score encoding to make DynamoDB's sort order work for numerical rankings.
And on-demand capacity to handle unpredictable traffic patterns.
But the most important lesson is the trade-off:
You don't have to make every operation equally simple. You need to make the critical operation scalable.
For this challenge, the critical operation is the score submission.
So I chose to distribute the writes and accept some additional work when reconstructing the leaderboard.
That's what made this challenge interesting—and a great exercise in thinking about DynamoDB beyond simply storing data.
The database design isn't just an implementation detail. At scale, it becomes part of the application's architecture.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article