Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Preventing Stale Look-Aside Cache Pins
& Dead-Shard Thundering Herds.

A 10M RPS look-aside cache suffers 3,600s stale-data pins from concurrent read/write races and DB collapse when a cache shard fails; implement 64-bit leases and Gutter failover.
Start the journey2 stages· Last modified Dec 1, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When a cache shard dies or races with DB writes, leases reject stale sets and Gutter absorbs misses.

TL;DR30-second simplified summary
▾

Cuts stale pins to zero and prevents 100k QPS DB spikes on shard loss.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Look-aside caching
Memcache lease protocol
Gutter failover
Full walkthrough · 2 stages
01
Stage 1 • Diagnosisintermediate

Pinpointing the Stale-Set & Herd Race.

Why this matters: Trace the exact interleaving that pins stale values for 3,600s.

Reader A loads v1, stalls on GC, Writer B commits v2 and deletes cache, Reader A resumes and calls cache.set(v1).

02
Stage 2 • Solutionintermediate

Lease-Guarded Refill & Gutter Routing.

Why this matters: Implement lease_get/lease_set with Gutter fallback in Java.

Mcrouter/client checks shard health; if unreachable, it routes to Gutter with a 30s TTL so stale data cannot linger after the primary shard recovers.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why must Gutter entries use a short TTL (e.g., 30s) instead of 3,600s?

Recommended Learning Flow