Key points of Consistent Hashing
The key to understand Consistent Hashing is to understand the following:
We not only hash the key IDs but also the server/node IDs. Modulo hashing works well for a fixed number of servers. However in reality servers can go down and become unavailable; so a fixed number of servers cannot be assumed.
Server IDs are hashed to a fixed range. The key IDs are also hashed to the same fixed range. Can imagine this range to be like a circle.
The key IDs are then routed to the closest server in the clockwise direction (It can be anticlockwise as well, as long as the same direction is used for all the keys).
Finally, only a single hashing algorithm need not be used. We can use multiple hashing algorithms to make the servers spread out across the circle. Thus the load can be distributed in a better manner.
Ref:
Top comments (0)