Keys and nodes are hashed onto the same ring, and each key belongs to the first node clockwise from it. A node's place on the ring depends only on its own name, so adding a node takes over only the arcs just before its positions, and removing one hands its arcs to the next node: every other key stays where it is. Below, add and remove nodes, and give each node more positions on the ring to even out the load.
The ring in the panel is the hash space, starting at the top and running clockwise. Coloured arcs show which node owns each stretch; the small dots inside are the 40 sample keys. Add or remove a node and the keys that change owner glide to their new node, ringed so you can count them. A node turns red when it serves well above its share of requests.
1. Total data
2. Adding one node with hash mod N
3. Adding one node on the ring
4. How even the ring is
Step 1 is the storage estimate from the back-of-the-envelope chapter of Alex Xu's System Design Interview, Vol. 1, whose consistent hashing chapter this page follows. Step 2 follows from how modulo behaves. Step 3 assumes the new node's tokens claim its fair share, which is what many tokens per node make likely. Step 4 is a statistical rule of thumb: a node's share is the sum of T random arcs, and the relative spread of such a sum shrinks like 1 / √T. It is an approximation, not an exact bound; the ring above shows real values for the 40-key scene.
Amazon's Dynamo paper made the ring with virtual nodes well known; Cassandra is built on the same design.
num_tokens setting defaults to 16 in the 5.0 configuration reference, down from the 256 once needed with random tokens.The Dynamo paper is a peer-reviewed paper by Amazon engineers (SOSP 2007); the Cassandra pages are the Apache project's official documentation. Quoted phrases are short attributed quotations; everything else is described in our words.