Cache stampede at TTL boundary

On-call incidentMedium30 min

Your task

A product-listing page is cached in Redis with a 5-minute TTL; the underlying query is an expensive aggregation against Postgres. Normally the DB is at 15% CPU. At round 5-minute marks (12:00, 12:05, ...) the DB briefly pegs at 100% CPU, query queue depth explodes, and the page p99 spikes to several seconds, then recovers. Traffic to the page is high and steady. A recent change unified the TTL across all listing keys. Triage, mitigate the spikes, and prevent recurrence.

It covers

  • Cache stampede
  • Thundering herd
  • Db overload