Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Sharding: splitting the ledger

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.

Saved in this browser, and to your account when you sign in.