Katkat

Design consistent hashing with a sorted map

DoorDashSoftware Engineer · Technical Screen

Last updated

This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Design consistent hashing with a sorted map states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Design and implement consistent hashing to distribute keys across a dynamic set of backend nodes. Use a sorted map (e.g., a TreeMap keyed by hash values) to find the next node clockwise from a key’s hash. Specify the hash function choice, how many virtual nodes to use and why, and how to handle node additions/removals with minimal key movement. Provide APIs for put/get that map keys to nodes, analyze time/space complexity, and discuss failure handling, rebalancing, and testing strategies.