0
0
HLDsystem_design~20 mins

Consistent hashing in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Consistent Hashing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of consistent hashing

Why is consistent hashing preferred over traditional hashing methods in distributed systems?

ABecause it evenly distributes keys and minimizes reassignments when nodes change
BBecause it uses less memory than traditional hashing
CBecause it guarantees zero collisions between keys
DBecause it requires no hashing function at all
Attempts:
2 left
💡 Hint

Think about what happens when a server is added or removed in a distributed cache.

Architecture
intermediate
2:00remaining
Designing a consistent hashing ring

You need to design a consistent hashing ring for 4 cache servers. Which approach correctly represents the ring structure?

AUse a linear list of servers and assign keys based on server index
BAssign keys randomly to any server without a ring structure
CAssign all keys to the first server and switch when it fails
DPlace servers on a circular hash space and assign keys to the next clockwise server
Attempts:
2 left
💡 Hint

Visualize a clock face where servers are points on the circle.

scaling
advanced
2:00remaining
Handling node additions in consistent hashing

When a new node is added to a consistent hashing ring, what is the impact on key distribution?

AOnly keys that map between the new node and its predecessor move to the new node
BAll keys are redistributed evenly among all nodes
CNo keys move because the ring is static
DKeys assigned to the last node move to the new node
Attempts:
2 left
💡 Hint

Consider which keys fall between the new node and the previous node on the ring.

tradeoff
advanced
2:00remaining
Tradeoffs of using virtual nodes in consistent hashing

What is a key tradeoff when using virtual nodes (vnodes) in consistent hashing?

AReduced load balancing but simpler implementation
BImproved load balancing but increased complexity in node management
CNo change in load balancing but higher memory usage
DEliminates the need for hashing functions
Attempts:
2 left
💡 Hint

Think about how virtual nodes affect distribution and system complexity.

estimation
expert
3:00remaining
Estimating key remapping after node failure

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?

AAbout 100,000 keys
BAbout 1,000 keys
CAbout 10,000 keys
DAll 1 million keys
Attempts:
2 left
💡 Hint

Consider the fraction of the ring that one node covers.