Preparing your design workspace

Loading the problem and your latest saved attempt…

Cache Avalanche Resilience

Design a cache-backed read service that prevents synchronized misses from overwhelming its authoritative database.

Problem statement

For this exercise, assume a read-heavy catalog service uses a distributed cache in front of an authoritative database. It must remain available when many popular keys expire together or the cache fleet restarts.

Design expiration, miss handling, origin protection, warm-up, and recovery so admitted database traffic stays below its safe capacity. During an incident, a request may wait briefly or receive a recently stale value, but the system must expose that decision and recover to normal freshness without a second surge.

Exclude writes to catalog data and cache/database consistency after writes; focus on cache avalanche prevention and recovery.

What to build

  1. Serve catalog reads from cache when fresh and load authoritative data when a controlled miss is admitted.
  2. Prevent large groups of cache entries from becoming hard misses at the same instant.
  3. Coalesce duplicate fills and enforce an origin-read budget during miss bursts.
  4. Restore hot cache coverage after mass expiry or a fleet restart without causing a second overload wave.

At scale

  • Assume 1,000,000 cacheable keys and 50,000 reads per second with bursts up to ten times normal traffic.
  • Assume a healthy cache-hit rate of 97 percent and an authoritative database safe limit of 5,000 reads per second.
  • Assume p95 read latency should remain below 150 milliseconds when healthy and monthly availability should reach 99.9 percent.
  • Assume stale-if-error responses may use a value no more than 60 seconds beyond its soft expiry during a declared incident.