SystemKit

Consistent Hashing

How to place data across nodes so that adding or losing one moves as little as possible. Covers the hash ring, virtual nodes, replica placement, and what balance really means when some keys are far hotter than others.

Lessons

  1. 01Know what the mapping must preserveA partition function assigns each key to an owner and determines how much data moves when capacity changes.
  2. 02See why modulo causes churnChanging the server count changes the divisor for every key.
  3. 03Place keys and nodes on a ringEach key belongs to the first node encountered clockwise from its hash position.
  4. 04Move only affected rangesA new token takes the interval immediately before it; its successor otherwise keeps its keys.
  5. 05Use multiple tokens per physical nodeVirtual nodes reduce uneven range sizes and can reflect unequal hardware capacity.
  6. 06Separate ownership from redundancyThe primary mapping picks an owner; a replica policy decides where copies live.
  7. 07Keep routing trustworthy during changeVersion the ring, measure skew, and rehearse data movement before a failure forces it.