DBRaven
Cache CollapseCritical

Redis Cache Collapse Under Stampede

A cache key (or key namespace) expires or is evicted simultaneously for many users. Thousands of requests hit the database to recompute the same value: a cache stampede. The database becomes overwhelmed, latency spikes, and the cache fills too slowly to absorb the flood, causing a self-reinforcing collapse loop.

Redis cache layer + PostgreSQL primary + application server pool

Degradation Replay

Stage 1

Nominal: Cache Warm

Nominal
Trigger

All hot keys cached; cache hit rate > 95%

Operational Metrics
Cache Hit Rate
97 %
warn 80crit 60

Critical: 97 exceeds critical threshold of 60 %

Database QPS
120 qps
warn 800crit 1,500
P99 Response Time
12 ms
warn 100crit 500
Symptoms
  • ·Cache hit rate 95-99%: near-zero DB reads for cached paths
  • ·Response latency driven by Redis RTT (~1ms)
Topology Effects
  • ·Redis serving majority of read traffic
  • ·PostgreSQL only sees writes and uncached reads
Operational Consequences
  • !Normal operation: users see fast responses

Operational simulation model only, not a production forecast. Degradation stages are derived from structured operational knowledge, not measured telemetry. Do not use for capacity planning or incident response.

Run With Your Parameters

Adjust the parameters below to see how metric values shift across degradation stages. Formulas are deterministic: same inputs always produce the same output.

Simulation Parameters

Steady-state request rate

Peak traffic as a multiple of baseline

Total Redis memory allocated to the cache

Hot data size accessed at peak load

Computed Degradation Stages

nominal·Nominal: Cache Warm

All hot keys cached; cache hit rate > 95%

Cache Hit Rate
0%
warn: 80crit: 60
Database QPS
6,000qps
warn: 2,500crit: 7,500
DB Connection Pool Utilization
99.9%
warn: 70crit: 90
Cache Miss Rate
6,000req/s
warn: 1,500crit: 3,500
warning·Key Expiry: Stampede Begins

Hot cache key expires; first wave of concurrent misses hits DB

Cache Hit Rate
0%
warn: 80crit: 60
Database QPS
12,750qps
warn: 2,500crit: 7,500
DB Connection Pool Utilization
99.9%
warn: 70crit: 90
Cache Miss Rate
12,750req/s
warn: 1,500crit: 3,500
critical·Critical: DB Overwhelm + Collapse Loop

DB slow under load; slow response delays cache repopulation; collapse self-reinforces

Cache Hit Rate
0%
warn: 80crit: 60
Database QPS
16,500qps
warn: 2,500crit: 7,500
DB Connection Pool Utilization
99.9%
warn: 70crit: 90
Cache Miss Rate
16,500req/s
warn: 1,500crit: 3,500
recovery·Recovery: Cache Repopulates

DB query completes; first value written to cache; hit rate begins recovering

Cache Hit Rate
20%
warn: 80crit: 60
Database QPS
6,000qps
warn: 2,500crit: 7,500
DB Connection Pool Utilization
99.9%
warn: 70crit: 90
Cache Miss Rate
6,000req/s
warn: 1,500crit: 3,500

Threshold Events

Cache Hit Rate Below 80%critical

Cache hit rate at 0%: working set (800 MB) exceeds cache (512 MB) under 0.4× peak load.

threshold: 80actual: 0
DB Pool Saturatedcritical

DB connection pool at 100%: cache misses driving database load. Miss rate: 6000 req/s against a 100-connection pool.

threshold: 90actual: 99.9

Interpretation

critical

At 3.0× peak with 512 MB cache and 800 MB working set, cache hit rate collapses to 0%. DB connection pool reaches 100%.

Bottleneck

Cache working set exceeds capacity → stampede → DB overload

Recommendation

Increase cache to 1040 MB to absorb full working set at peak. Add probabilistic early expiry (PER) or mutex-based single-flight to prevent stampede. Implement stale-while-revalidate to serve slightly stale data during repopulation.

Parameterized simulation: not a production forecast. Values derived from deterministic formulas applied to your parameters. Do not use for capacity planning or operational decisions without validation.

Propagation Model

Exponentialmoderate amplification
Redis CachePostgreSQL Primary, Application Servers

Each cache miss triggers a DB query; concurrent misses for same key produce N identical DB queries: thundering herd

Stabilizes: First DB response populates cache; subsequent requests hit cache again

Feedback Loopmoderate amplification
PostgreSQL PrimaryRedis Cache Repopulation

DB under pressure responds slowly; slow response delays cache repopulation; more misses accumulate

Stabilizes: Cache repopulates once DB pressure subsides: but requires DB to recover first

Cascademoderate amplification
Application Server PoolDB Connection Pool

Requests waiting on DB exhaust connection pool; new requests queue or error

Stabilizes: Connection pool drains once DB queries resolve

Recovery Patterns

Manual cache pre-warm

1-5 minutes with scripted warm-up
Tradeoffs
  • ·Requires ops runbook and access to a known-good data source
  • ·Pre-warm data may be slightly stale: acceptable during incident
Residual Risks
  • !If trigger was memory pressure, pre-warm may be evicted again immediately

Self-healing via DB query completion

30-120 seconds for hot keys to repopulate
Tradeoffs
  • ·DB must survive the stampede flood: may require traffic throttling
Residual Risks
  • !If DB is overwhelmed and cannot respond, cache never repopulates: deadlock

Operational Summary

Cache stampedes occur when many concurrent requests miss the same expired key simultaneously. The thundering herd amplifies DB load N-fold (N = concurrency). The critical failure mode is a self-reinforcing collapse: DB pressure slows cache repopulation, which keeps hit rate low, which sustains DB pressure. Prevention requires TTL jitter, stale-while-revalidate, or request coalescing (mutex).