System Design · Senior · Question 4 of 75
Why use consistent hashing when adding cache nodes?
- ✓Correct answer: When the number of nodes changes, only a small share of keys move
- 2It guarantees that all keys are stored on all nodes
- 3It encrypts keys so nodes can't see each other's data
Explanation
With hash(key) % N, changing N redistributes almost all keys and the cache misses en masse. A hash ring (with virtual nodes) moves only ~1/N of the keys. Used in distributed caches, CDNs and databases.