HardπŸ‘€ 8-15 years 1 min read

How would you design a distributed cache like Redis Cluster?

Asked inAmazonGoogleMicrosoft
#distributed cache#redis#consistent hashing#replication#eviction
Report issue

⚑ Short Answer

Partition keys across nodes with consistent hashing, replicate each shard (primary + replicas) for availability with automatic failover, and evict via LRU/LFU under memory pressure with TTLs. Handle hot keys (replication/local cache), cache stampedes (single-flight), and decide the consistency model (usually eventual).

β˜•Coffee Chat Question

Concept Made Simple

β€œHow would you design a distributed cache like Redis Cluster?”

🧠Mind Map Answer

Remember It Faster

Partition→consistent hashing across nodes
Replicate→primary + replicas, auto-failover
Evict→LRU/LFU + TTL under pressure
Handle→hot keys, stampedes, consistency

πŸ”₯What If?

Think Beyond the Expected

One key is so hot it overloads its shard's node β€” how do you handle it?

Replicate that hot key to multiple nodes and read from any (or add a small local/client-side cache in front), and use single-flight to prevent stampedes. Consistent hashing spreads keys, but a single super-hot key still needs replication or client-side caching to spread the read load.

πŸ˜‚Real World

Redis Cluster/Memcached designs combine consistent hashing, replication + failover, and eviction; the hard parts in interviews are hot keys, stampedes, and the consistency/availability trade-off.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ consistent hashing partitioningβœ“ replication + failoverβœ“ LRU/LFU + TTL evictionβœ“ hot-key handlingβœ“ stampede preventionβœ“ consistency model

⚠️Common Mistakes

  • βœ—No hot-key strategy
  • βœ—No replication (cache node failure = thundering herd)
  • βœ—Ignoring eviction policy tuning

βœ…Best Practices

  • βœ“Consistent hashing + replication + failover
  • βœ“TTL + LRU/LFU; single-flight loads
  • βœ“Replicate/local-cache hot keys

πŸ”Follow-up Questions

  • 1How does failover pick a new primary?
  • 2LRU vs LFU eviction β€” when each?
  • 3How do you keep the cache consistent with the DB?

🧩Related Technologies

Redis ClusterMemcachedconsistent hashing

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β€” AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Caching (System Design)
Interview question: "How would you design a distributed cache like Redis Cluster?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission β€” at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions