Skip to content
System Designer

Scale the data · 3 minutes

When one item is popular

Sharding spreads keys, not popularity. One star item can still overload one shard.

Open this lesson
Sharding spreads keys, not popularity. One star item can still overload one shard.

The celebrity problem

Shards split keys evenly, but not attention. If one post goes viral, every request for it lands on the one shard that holds it. That shard melts while the others sit idle.

Ways out

Adding shards spreads different keys. It does not divide the work on one popular key. Try coalescing those reads.

Try the idea

One item gets a third of all reads. Protect the shards with a cache.

Key numbers

One shard handles
≈ 1/6 of traffic when even. with six shards
A hot item with 30 percent of reads
≈ 2.5 times a fair share on its shard. its shard carries 30 + 70 ÷ 6 ≈ 42 percent of reads, against a fair 16.7 percent: 42 ÷ 16.7 ≈ 2.5
Cache answer
≈ 0.5 ms. approx.

Check your reasoning

Think through these questions before opening the lesson. In the game you can test the idea and compare your reasoning.

  • Does adding shards fix a hot key?
  • Which is a good fix?
  • Why do hot keys surprise teams?

The key point

Spread keys with shards and spread attention with caches and copies.

Practise this idea

Continue through the lesson tracks