⬡ ScalingAdvanced interactive
Consistent Hashing
Add or remove nodes without reshuffling everything.
consistent_hashing
3 nodes
Each key maps to the next node clockwise around the ring.
How it works
Consistent hashing maps both keys and servers onto a ring, so each key belongs to the next server clockwise. Adding or removing a node only moves the keys in one arc — not the whole keyspace — making it ideal for distributed caches and sharded stores.
Mental models
- Keys and nodes share one hash ring; a key goes to the next node clockwise.
- Virtual nodes smooth out uneven key distribution.
- Removing a node only reassigns its arc — minimal data movement.
Reach for it when
- Distributed caches
- Sharded databases
- P2P / DHT systems