In the past, when I was doing a project, I simply studied consistent hash. Later, when I looked at the implementation principle of dynamo, I didn't quite understand the virtual nodes in it, and I still didn't find any good materials to explain this problem, yesterday, I happened to see a web crawler in guanggu bookstore and analyzed the problem. Today I found some information on the Internet to deepen my understanding of this issue.
Principle of consistent hash: http://blog.csdn.net/sparkliang/archive/2010/02/02/5279393.aspx
Java implementation code of ketama consistent hash algorithm: http://www.javaeye.com/topic/684087
Ketama. Net implementation code: http://www.cnblogs.com/daizhj/archive/2010/08/24/1807324.html
After figuring out the problem of virtual nodes, I found that even though the introduction of virtual nodes balances the distribution of keys (when some nodes are launched, keys on the node are evenly distributed to other nodes), and consistent hash is maintained. However, if dynamo maintains multiple replicas for each key, it can directly place the replicas on consecutive nodes. How should we place the replicas after using virtual nodes, several consecutive virtual nodes may correspond to a physical node. You cannot place copies on a physical node. The most intuitive method is round robin, until we find N (number of replicas) virtual nodes corresponding to different physical nodes, Dynamo does this.