How would you choose the number of virtual nodes per server? What do you gain and lose by raising it?
Sketch your own answer first, then compare it with the one below.
A strong answer
Raising the count improves balance. The busiest node's share gets closer to the average as more points are averaged. Removal is also gentler, because a failed node's keys spread over many neighbours.
The costs are real:
- Ring size and memory grow with nodes times virtual nodes.
- Rebuilding or updating the sorted structure after a change takes longer, and replicating the ring metadata to clients takes more bandwidth.
- When replicas go on the next distinct physical nodes, more points make the walk to find distinct nodes touch more entries.
- Rebalancing data when a node joins involves many small ranges from many sources, which can be more operationally complicated than a few large transfers.
The returns diminish: past some point the extra balance is not worth the overhead. A defensible approach is to pick the smallest count that keeps imbalance within a target, measured with your key distribution, and to weight by machine capacity.
Balancing keys is not balancing requests, so hot keys stay a separate problem.
Sources
- Giuseppe DeCandia, Deniz Hastorun, Madan Jampani, Gunavardhan Kakulapati, Avinash Lakshman, Alex Pilchin, Swaminathan Sivasubramanian, Peter Vosshall, Werner Vogels (2007). Dynamo: Amazon's Highly Available Key-value Store.