Hot keys
A celebrity joins Pixel, and the photos she posts draw likes from everywhere. What does one very popular user do to a ring of five shards?
13 minMediumStation: Hot keysMembers lesson
Membership isn’t open yet. The free lessons are open — 16 of them, including the whole first leg of the Scale Line.
- Sharding
- Consistent hashing
- Hot keys
- Multi-region
- Celebrity day
What you'll be able to do
- 1Explain why adding shards doesn't cool a hot key, since every request for a key goes to the one shard that owns it.
- 2Predict the busiest shard's load from the share of traffic its hottest keys draw, and whether it goes over that shard's capacity.
- 3Choose a fix for a hot key — cache its reads, split its writes over sub-keys, or isolate it — and name what each one costs.
Inside the lesson
- steps
- 12
- questions
- 8
- simulations
- 3
You guess first, then run the system and see if you were right.
Step 1 · The setup
Pixel now runs five shards on a ring, 256 points each. Its 480 writes a second split almost evenly — about 96 per shard, each shard about half busy. Together the five could take a little over 900.
Then a celebrity joins. Her first post goes viral: 200 likes and comments a second on her photos. As at the sharding stop, a like or comment is stored with the photo's owner — so every one of them is keyed by her user id.
Steps 2–12 are for members
More on the Scale Line
- Latency & percentilesOpen8 min
- Server capacity & scaling upFree with an account10 min
- Split app and database tiersFree with an account10 min
- Load balancerFree with an account10 min
- Horizontal scaling with a stateless tierFree with an account10 min
- Cache-asideFree with an account10 min
- Object storage for user filesMembers10 min
- A CDN for the files everyone wantsMembers12 min