Consistent hashing, and why `hash % N` breaks on the day you scale
Placing a key on a machine looks like a one-line problem until the machine count changes. This measures how much data `hash % N` moves when you add a node, builds the ring that fixes it, shows why the ring is lumpy without virtual nodes, and names what consistent hashing still does not solve.
What you'll be able to do
- Quantify the fraction of keys remapped by modulo hashing versus a hash ring when a node is added
- Implement a hash ring with virtual nodes and explain what the replica count buys
- Diagnose a hot shard, and distinguish a hot key from an unbalanced ring
- Name the problems consistent hashing does not solve, and what to use instead
Before this: picking-a-datastore
The rest of this lesson is in the app
Placing a key on a machine looks like a one-line problem until the machine count changes. This measures how much data `hash % N` moves when you add a node, builds the ring that fixes it, shows why the ring is lumpy without virtual nodes, and names what consistent hashing still does not solve. This walkthrough runs about 24 minutes, with runnable code you can edit and re-run as you read.
Continue in ChannelPulseThe first module of every track is free to read on the web — see what's open in System design.