Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
System Design, Redis & Distributed Systems 10+ Years (Principal / Architect) Hard Production Scenario

How does Consistent Hashing minimize data movement during Cache Cluster node addition or removal?

Real-World Scenario / Incident Description

Adding a 5th Memcached server caused 80% of existing cache keys to remap and miss simultaneously using standard `hash(key) % N`.

786 views • Updated 1 month ago

Consistent Hashing Ring

  1. Maps both Cache Servers and Keys onto a 360-degree circular hash ring (e.g. 0 to $2^{32}-1$).
  2. A key is assigned to the nearest server located clockwise on the ring.
  3. When a server is added or removed, only $K/N$ keys need remapping, preventing total cache thrashing.
  4. Virtual Nodes: Assigns multiple virtual points per physical server to ensure even distribution across nodes.
Related Concepts: #Consistent Hashing #Virtual Nodes #Caching #Distributed Systems