📖 Book · system design · high

📐 Consistent hashing

Shard keys so adding or removing a node remaps ~1/N of them, not all of them.

Why hash(key) % N reshuffles everything when N changes, and how a consistent-hash ring fixes it: keys route to the next node clockwise (runnable, O(log N) via std::map), and virtual nodes keep the load balanced. The standard sharding question.

3 chapters▶ runnable code✦ in-depth animation

What this book covers

  1. 01Why not just hash(key) % N?
  2. 02The hash ring — run it
  3. 03Virtual nodes: making it balanced

Read it in full — runnable C++ + step-through animations

Every chapter of Consistent hashing ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.