Skip to Content

A hashing scheme where adding or removing a node disrupts only a small slice of keys.

Data Flow

        hash ring 0..2^32-1
        N1,N2,N3,N4 placed at hashed positions

        key K -> hash(K) -> walk clockwise -> first node

        if N4 dies: only keys between N4 and N3 reshuffle
        if you remove N4 and add N5: only a slice moves

Why it works

Standard hash modulo N: when N changes, ~ 100% of keys move. Consistent hash: when one node changes, only 1/N of keys move on average.

Pitfalls

Analogy

A circular dinner table: when a chair is removed, only the guests between that chair and the next move.

Interview tip: Explain vnodes and why they balance load.

Advertisement