Partitioning
A celebrity is not a hash problem
Before you start
- Open lesson
Partitioning
Keys are spread over nodes by hashing. That lesson covers the ring.
Why it matters
Viewer-id partitioning keeps an ordinary home read in one place, yet two extreme cases remain. A celebrity post targets 20 million different viewer timelines, while one shared-screen viewer can send 50,000 reads per second to a single key. The normal user’s home must stay a one-partition read while neither hotspot overwhelms its owning partitions.
Example
Rebalance a hot celebrity
Timelines are partitioned by viewer id. One viewer is fine. The problem is a celebrity post that writes every viewer, and one viewer whose home is read constantly is a different hotspot.
Mental model
The idea
Keep one example in view
Rebalance a hot celebrity
Timelines are partitioned by viewer id. One viewer is fine. The problem is a celebrity post that writes every viewer, and one viewer whose home is read constantly is a different hotspot.
Keep this exact scenario and its constraint in view while you build the model.
Viewer hashing cannot shrink a 20-million-write celebrity post or split one 50,000-read viewer key. Store the celebrity post once and merge it on home reads; replicate the shared-screen viewer’s hot result while normal homes stay on one partition.
The celebrity write already spreads across viewer partitions, but its total remains 20 million. Store that post once in the celebrity’s recent list and merge it into each follower’s home when they read; ordinary authors continue using the normal timeline path.
The 50,000-read shared-screen viewer is a different shape: every request names the same viewer key. Cache its rendered home in several places or add read copies for that key. This multiplies read capacity, but updates must invalidate or refresh those copies.
Visual anchor
Rebalance a hot celebrity
Pro
The rest of this is on Pro
The idea above is free. The walkthrough, the cost, and the practice are on Pro.