Hot Spots
The celebrity problem.
Even a perfect shard key can fail. Imagine a celebrity with fifty million followers posts a photo. Every like and comment hits the one shard that holds that post. That shard is now a hot spot.

- A perfect key can still fail
- A celebrity posts
- One shard is overloaded
Fixing hot spots
There are a few standard fixes. Cache the hot item, so most reads never reach the shard. Split the hot key into several sub keys, like post forty two, part one to ten, and add the counts together when reading. Give the biggest accounts their own handling. And watch your metrics, so you spot hot shards early.
Splitting a hot counter
Here's the split key idea for a like counter. Instead of one counter, we keep ten, and each like goes to a random one. Run it. The thousand likes are spread across ten counters, so no single counter is hammered. When we need the total, we add them up.
import random
random.seed(1)
counters = {f"post42#{i}": 0 for i in range(10)}
for _ in range(1000):
part = random.randrange(10)
counters[f"post42#{part}"] += 1
print("per counter:", list(counters.values()))
print("total likes:", sum(counters.values()))per counter: [98, 101, 93, 96, 112, 92, 102, 89, 119, 98] total likes: 1000
Summary
Hot spots happen when one key gets far more traffic than others. Cache it, split it, or handle it specially. Next, a famous theorem about distributed data. CAP.
Key takeaways- One key, too much traffic
- Cache or split
- Watch for it