Skip to content

Consistent hashing, explained with a ring you can draw

Arjun RaoPosted · 1 min read

With hash(key) % n, adding one server moves almost every key. Consistent hashing moves only about 1/n of them.

Put servers and keys on the same ring of hash values. Each key belongs to the first server clockwise from it. Adding a server only takes keys from its clockwise neighbour.

Real systems give each server many virtual nodes on the ring, so load stays even when a server joins or leaves.

Text by Arjun Rao, licensed under CC BY-SA 4.0. You may share and adapt it with credit to the author, under the same licence.

Comments

Loading comments…