PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/System Design/DoorDash

Design consistent hashing with a sorted map

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of consistent hashing, virtual nodes, sorted-map ring representation, replication and quorum strategies, membership changes and failure handling, complexity analysis, and testing considerations for distributed key-value or cache sharding systems.

  • medium
  • DoorDash
  • System Design
  • Software Engineer

Design consistent hashing with a sorted map

Company: DoorDash

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Technical Screen

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.

Quick Answer: This question evaluates understanding of consistent hashing, virtual nodes, sorted-map ring representation, replication and quorum strategies, membership changes and failure handling, complexity analysis, and testing considerations for distributed key-value or cache sharding systems.

Related Interview Questions

  • Design a Food Rating System - DoorDash (medium)
  • Design a resilient bootstrap API - DoorDash (medium)
  • Design Real-Time Driver Pay Aggregation - DoorDash (hard)
  • Design Food Ratings and Driver Payouts - DoorDash (medium)
  • Design personalized restaurant search and recommendations - DoorDash (medium)
DoorDash logo
DoorDash
Aug 7, 2025, 12:00 AM
Software Engineer
Technical Screen
System Design
14
0

Consistent Hashing with a Sorted Map (Virtual Nodes)

Context

You are building a client-side library to map arbitrary keys to backend nodes (cache/storage shards) that can be added or removed at runtime with minimal remapping. Represent the consistent hash ring with a sorted map (e.g., a TreeMap keyed by 64-bit hash tokens). Lookups should find the next node clockwise from a key's hash, with wrap-around to the beginning of the ring.

Requirements

  1. Hashing and Ring
  • Choose a hash function; justify the choice.
  • Use virtual nodes; specify how many per physical node and why. Support weights for heterogeneous node capacity.
  • Represent the ring using a sorted map keyed by hash tokens.
  1. Membership Changes
  • Implement addNode/removeNode with minimal key movement.
  • Handle wrap-around and token collisions.
  1. APIs
  • getNodeForKey(key) and getNNodesForKey(key, R) for replication.
  • put(key, value) and get(key) that route to the selected node(s). You may simulate per-node storage in-process.
  1. Complexity
  • Analyze time and space complexity for lookup, add, remove, and put/get with replication factor R.
  1. Reliability and Operations
  • Discuss node failure detection and what happens when a node is down.
  • Replication strategy, read/write quorum options, rebalancing, and capacity weighting.
  1. Testing
  • Outline tests for correctness, distribution fairness, churn (add/remove), and failure scenarios.

Assume a single-process demo is fine. Use any language with a sorted map (e.g., TreeMap) and include code for the library and a brief example.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More DoorDash•More Software Engineer•DoorDash Software Engineer•DoorDash System Design•Software Engineer System Design
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.