educative.io

Educative

Does consistent hashing require a master job?

The article does not mention a master job, but if the vnodes are assigned randomly, how do you know which vnode is assigned to which actual node? Does each node keep a copy of this table?

Consistent Hashing does not have a master job or a leader node, it is completely decentralized. The tokens or vnodes assignment is implemented in the consistent hashing code which runs on each node; that is how every node on the ring know where will a particular key be stored. Take a look at the code for how vnodes get assigned to physical nodes; here is an example of the code implementing consistent hashing algorithm: https://docs.openstack.org/swift/pike/ring_background.html

1 Like

IMO random assignment is an edge-case. Often we apply consistent hashing to mitigate hotspots. As I see in that case a master node is inevitable. The master has to monitor the key range hotness across the cluster and adapt the vnode assignment accordingly. Alternatively, all servers can monitor the key range hotness but in that case you have to solve the problem of distributing the usage stats across the nodes that’ll lead you back to having a master node or applying some consensus algorithm.