Why is consistent hashing preferred over traditional hashing methods in distributed systems?
Think about what happens when a server is added or removed in a distributed cache.
Consistent hashing evenly distributes keys and minimizes the number of keys that need to be reassigned when nodes join or leave, unlike traditional hashing which can cause many keys to move.
You need to design a consistent hashing ring for 4 cache servers. Which approach correctly represents the ring structure?
Visualize a clock face where servers are points on the circle.
Consistent hashing uses a circular hash space where each server is placed on the ring. Keys are assigned to the next server clockwise, ensuring balanced distribution and minimal movement on changes.
When a new node is added to a consistent hashing ring, what is the impact on key distribution?
Consider which keys fall between the new node and the previous node on the ring.
Adding a node only affects keys that fall between the new node and its predecessor on the ring, minimizing key movement and maintaining balance.
What is a key tradeoff when using virtual nodes (vnodes) in consistent hashing?
Think about how virtual nodes affect distribution and system complexity.
Virtual nodes improve load balancing by spreading each physical node across the ring multiple times, but they add complexity in tracking and managing these virtual nodes.
In a consistent hashing ring with 100 nodes and 1 million keys evenly distributed, approximately how many keys need to be remapped if one node fails?
Consider the fraction of the ring that one node covers.
Each node is responsible for roughly 1/100th of the keys, so when one node fails, about 1% of keys (10,000) need remapping.