Consistent hashing is a technique for distributing data across nodes (servers) that minimizes redistribution when nodes are added or removed — unlike simple hashing, which remaps most keys when the node count changes. It's important for distributed caches, databases, and load distribution.
The problem with simple hashing
Simple approach: node = hash(key) % N (N = number of nodes)
✗ when N CHANGES (add/remove a node), N changes → MOST keys remap to different nodes →
massive data movement / cache invalidation (almost everything moves!)
→ adding/removing a server causes huge disruption → bad for dynamic distributed systems.
