Implement consistent hashing ring
DoorDashSoftware Engineer · Technical ScreenLast updated
This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Implement consistent hashing ring states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Implement consistent hashing for routing keys to servers. Provide APIs addNode(nodeId, weight), removeNode(nodeId), and getNode(key). Use virtual nodes to balance load and ensure minimal key remapping when nodes join/leave. Explain hash choice, collision handling, and how you pick the number of virtual nodes. Analyze time/space complexity and compare with modulo hashing.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.