How does consistent hashing work and why is it used in distributed caches?
Reported in Instacart USA engineering loops. Frequently asked in US system design rounds for CDN, cache, and sharding topics.
Interview scenario
Often asked in Instacart on-site or virtual loops at US offices (Bay Area, Seattle, NYC, Austin, and remote US). Prepare a clear spoken answer plus key trade-offs.
Model answer
Try answering aloud first
Cover trade-offs, structure, and a concrete example before revealing the baseline response.
How to frame this at Instacart: Connect your answer to measurable impact, clarity of thought, and trade-offs the team cares about. Below is a strong baseline response you can adapt with your own project examples.
Problem: naive hash mod N remaps almost all keys when nodes are added/removed, causing cache stampedes.
Consistent hashing maps nodes and keys onto a ring (0..2^32-1). Key goes to the first node clockwise. Adding a node only moves keys in its adjacent arc—minimal disruption.
Virtual nodes: each physical node owns many points on the ring for even load distribution. Used in Dynamo, Cassandra, Memcached clients, and CDNs.
Discuss replication (successor nodes), hotspot mitigation, and monitoring skew. Time complexity O(log N) with balanced trees for ring lookup.
Discussion
Comments (0)
Share how this question came up in your loop, or add tips for others preparing.
Log in to comment on this question.