Consistent Hashing
What Is It?
Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers in a cluster. It ensures that when servers are added or removed, only a minimal number of keys (roughly $K/N$, where $K$ is the number of keys and $N$ is the number of servers) are redistributed.
Understanding Hashing First 🔑
Before diving into consistent hashing, let's understand what hashing is at its core.
1. What is Hashing?
Hashing is the process of taking an input of any size (a word, a file, a video, or an entire database row) and passing it through a mathematical formula (a Hash Function ) to produce a fixed-size string of characters or numbers, known as a Hash Value , Hash Code , or simply a Hash .
┌───────────────┐ ┌───────────────┐ ┌──────────────┐ │ Input Data │ ─────► │ Hash Function │ ─────► │ Hash Value │ │ (Any length) │ └───────────────┘ │ (Fixed size) │ └───────────────┘ └──────────────┘
Enter fullscreen mode
Exit fullscreen mode
Real-World…