.NET Architecture & System Design Interview Question #62
What is consistent hashing?
Database Scaling, Partitioning, NoSQL & Data Consistency Mid-Level Intermediate
Quick Interview Answer
Consistent hashing is a technique for mapping keys to nodes so that adding or removing a node causes only a portion of keys to move rather than remapping nearly the entire dataset.
Detailed Explanation
Consistent hashing is a technique for mapping keys to nodes so that adding or removing a node causes only a portion of keys to move rather than remapping nearly the entire dataset.
It is useful in distributed caches and partitioned systems. Real implementations may use virtual nodes or other balancing techniques to improve distribution.
Code Example
Hash ring:
Node A ---- Node B ---- Node C
Key -> next responsible node on ring
Add Node D -> only nearby key ranges move