Sharding: splitting the ledger
Vertical version.
Chapters
Narration
The copy clerks scaled the reads and left the writes exactly where they were. Every change still lands in one book. Replication copies the same data many times. To scale writes you have to split different data instead. So you cut the ledger in two. A shard key, say the customer name, decides which book a write belongs to. A through M here, N through Z there. Two books, two pens, writes running in parallel. There are two ways to pick the book. Ranges keep neighbours together, so a scan reads one shard, but real data is lopsided. Hashing spreads it evenly and kills the skew, and now a scan has to touch every shard you own. Pick the key badly and you have not removed the wall, you have moved it. One celebrity customer, one popular range, and a single shard takes most of the traffic while the others sit there idle. The questions get more expensive too. List every order placed today used to read one book. Now it asks all of them and merges the answers in your application. Sharding is cheap by the key, and costly across it. And adding a shard under hash modulo N re-buckets nearly every key at once. Consistent hashing puts the nodes and the keys on a ring instead, so a new node only takes the slice sitting in front of it. Sharding is the only move that actually buys write capacity, and the whole craft of it collapses into one decision. The key you split on, chosen before you have the data, and painful to change afterwards.
Based on the board Splitting the Ledger.
Try it in the labs: Splitting the ledger and The ring.
Related papers: Dynamo: Amazon's Highly Available Key-value Store, MapReduce: Simplified Data Processing on Large Clusters and Consistent Hashing and Random Trees.
Covered in KV: the ring, Splitting the ledger (sharding), Changing the engine in flight (live schema and data migrations).
Saved in this browser, and to your account when you sign in.