Lesson 10 of 15
28. Consistent Hashing

Memory card and where the analogy breaks

3 min read+10 XP

The memory card (tear this page out)

#QuestionMemory code
28.1Mod-N problem?Count off again, and everyone changes host
28.2Hash ring?Seat everyone at a round table, by name, not by count
28.3Finding a key's server?Look to your right; the first host you see is yours
28.4Adding and removing?A new host only takes the guests right beside them
28.5Virtual nodes?Give every host many seats, and the work evens out
28.6Replication?Your backups are the next different hosts, not the same host in another seat
28.7Where it's used?Wherever helpers come and go, seat the crowd at a round table
28.8Rendezvous hashing?Every host bids for every guest; the highest bid wins

The whole chapter in one line: Put servers and keys on one circle, give each key to the next server clockwise, use many virtual nodes for even load, replicate to the next distinct servers, and only about 1/N of keys move when servers change.

Where the analogy breaks

  • Guests choose seats by name at random. Hash positions are random too, so without many seats per host, the split is uneven, which is the whole reason for virtual nodes.
  • A guest who changes host just walks over. A key that moves means a cache miss or copying data over the network, which is why minimising movement matters.
  • Everyone at a table sees who's sitting where. In a cluster, clients must agree on the list of servers, so membership needs its own mechanism (configuration, gossip or a coordinator).

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz