cloudpatterns.appClassroomKatasWhiteboardBlog
Scale LineLesson

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 keys

Members lesson

Membership isn’t open yet. The free lessons are open — 16 of them, including the whole first leg of the Scale Line.

  1. Sharding
  2. Consistent hashing
  3. Hot keys
  4. Multi-region
  5. Celebrity day
Scale Line — where this lesson sits

What you'll be able to do

  1. 1Explain why adding shards doesn't cool a hot key, since every request for a key goes to the one shard that owns it.
  2. 2Predict the busiest shard's load from the share of traffic its hottest keys draw, and whether it goes over that shard's capacity.
  3. 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