14 Comments
User's avatar
Priya Rathore's avatar

Thanks

Expand full comment
Shubhesh Tiwari's avatar

great article!!

Expand full comment
Naga Raj Aakurathi's avatar

Great article, it helped me to learn alot

Expand full comment
Omkar Singh's avatar

Thank you for this article.

Learned new things.

Expand full comment
Ravi Kumar Singh's avatar

With virtual node distribution can you share ring structure as well. This would be become more easy . Thank you for this article. One of the core concept in scaling of systems

Expand full comment
Ashish Pratap Singh's avatar

yeah.. good point. I will add the ring structure with virtual node distribution.

Expand full comment
YoyoB's avatar

Your writing is incredible, super concise but easy to understand, thanks for this! 🙌

Expand full comment
Ashish Pratap Singh's avatar

Great to hear this, thank you 😊

Expand full comment
David Dansby's avatar

Shouldn’t you be redistributing when you remove and add a node in the Python implementation?

Expand full comment
Ashish Pratap Singh's avatar

Explicitly redistributing isn’t required since inserting and removing hash values of servers in the sorted_keys data structure automatically takes care of it. Since sorted_keys is sorted by hash values, while adding and removing the order of other server hash values doesn't change.

Expand full comment
David Dansby's avatar

Got it, Thanks for answering so quickly

Expand full comment
Sampath's avatar

The article is really incredible, very helpful to understand the consistent hashing for a beginner like me.

I was wondering If it’s possible to have an edge case like 2 different virtual nodes sharing the same hash code(collision). If so how do we handle the remove servers when 2 virtual happen to share the same hash code.

Expand full comment
Ashish Pratap Singh's avatar

Great observation! While hash collisions are rare, they can still happen. In this implementation, the sorted_keys structure may store the same hash value for different virtual nodes. Currently, collisions aren’t explicitly handled, but they can be resolved by storing pairs {hash_value, virtual_node_id} instead of just hash values. This way, when removing a server, we can accurately identify and delete the correct virtual node, even if multiple nodes share the same hash.

Expand full comment
Sampath's avatar

Thanks for the quick reply

Expand full comment