EASYwalkthrough
Hash Ring Basics
How do we map keys to servers without reshuffling everything when a server dies? With modular hashing (hash % N), changing N from 5 to 4 remaps of keys.
The hash ring fixes this by mapping both keys and servers onto a circular space from 0 to . To find a key's server, walk clockwise from the key's hash position until you hit a server.
“At 500M keys, that is 400M cache misses hitting the database simultaneously.”
When a server is removed, only keys between it and its counter-clockwise neighbor move to the next clockwise server: 1/N of total keys, not . Akamai invented consistent hashing in 1997 to route CDN requests across 300,000+ edge servers.
Trade-off: the ring introduces a binary search lookup step and requires every proxy to hold ring metadata.
Related concepts