Design a low-latency Caching System
Quick Overview
Design a low-latency caching system handling millions of requests. Discuss consistency, availability, and performance trade-offs.
Walmart
5
Design a low-latency caching system handling millions of requests. Discuss consistency, availability, and performance trade-offs.
Walmart serves product pages, prices and availability to millions of shoppers, and spikes like Black Friday put enormous read pressure on the catalog and pricing databases. This technical screen checks whether you can put a fast cache in front of those stores while reasoning clearly about stale prices, eviction and what happens when a cache node fails.
What the Interviewer Expects
- Clarify read/write ratio, latency target and how stale a price or stock flag may be
- Estimate peak RPS and working-set size to size the cache cluster
- Choose a caching pattern (cache-aside, read-through, write-through) and justify it
- Explain eviction (LRU, TTL) and invalidation on price or inventory updates
- Cover sharding, replication and failover of the cache tier
- Discuss consistency versus latency trade-offs explicitly
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How would you prevent a cache stampede when a very popular product key expires?
- A price change must show up within 5 seconds everywhere. How does your invalidation change?
- How do you handle hot keys that overload a single Redis shard?
- What happens to the database if an entire cache region goes down?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional Requirements:
- Caching Layer: The system should cache frequently accessed product data (e.g., prices, availability) to reduce load on the primary database.
- Eviction Policy:...
Capacity Estimation
Assuming Walmart handles around 100 million requests per day during peak seasons:
- Requests per Second (RPS): 100 million / 86400 seconds = approx. 1157 RPS.
- Peak Load: Assume peak times se...