In distributed storage systems (e.g., Redis Cluster, Cassandra, DynamoDB), assigning data keys to server nodes using standard modulo hashing (hash(key) % N) causes catastrophic data movement whenever a node is added or removed ($N \to N+1$), forcing nearly 100% of keys to migrate.\n\n### 1. The Consistent Hash Ring\nConsistent hashing maps both server nodes and data keys onto a circular 360-degree integer space (e.g., a $2^{32}-1$ ring):\n1. Hash the Servers: Server IPs or hostnames are passed through a cryptographic hash function (e.g., MurmurHash3) and positioned on the ring.\n2. Hash the Keys: When a key arrives, its hash value is positioned on the ring.\n3. Clockwise Routing: Traverse clockwise from the key's position until the first physical server is encountered. That server owns the key.\n\n### 2. Node Addition and Removal\n* When a node is added, it only claims keys between itself and its immediate counter-clockwise predecessor. On average, only $K/N$ keys need migration (where $K$ is total keys and $N$ is nodes).\n\n### 3. The Hotspot Problem & Virtual Nodes (Vnodes)\nWith a small number of physical servers (e.g., 5 nodes), random hash placement produces unevenly sized ring segments, causing one server to hold 60% of data while another holds only 5% (Non-uniform data distribution).\n\n* The Solution: Virtual Nodes (Vnodes):\n Each physical server is mapped to multiple distinct points on the ring (e.g., 100 to 256 virtual positions per physical machine: ServerA#1, ServerA#2, ...).\n * Spreading hundreds of virtual nodes across the ring guarantees statistical uniformity.\n * Heterogeneous hardware can be supported naturally: a machine with 2x CPU/RAM is assigned 2x more virtual nodes.\n\n### Key Architectural Comparison\n| Hashing Model | Keys Migrated on Resize | Hotspot Protection | Hardware Heterogeneity Support | Production Example |
| :--- | :--- | :--- | :--- | :--- |
|---|---|---|---|---|
| Basic Consistent Hashing | $1/N$ of keys only | Poor (Vulnerable to ring clustering) | Difficult | Early distributed caches |
| Consistent Hashing with Vnodes | $1/N$ of keys only | Near-Perfect Uniformity (<2% skew) | Native (Assign more vnodes to larger servers) | Amazon DynamoDB, Apache Cassandra |\n