⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Databases & Storage Interview Questions Scenario 12 of 54 in Databases & Storage
Senior DevOps / SRE [L2] Database General DevOps — Scenario-Based Interview Questions Production Scenario [L2]
🎯 Target Role / Context: General DevOps Scenario #18 (L2) · General DevOps — Scenario-Based Interview Questions

Q: A Redis cache server is placed in front of a slow database. During a major marketing campaign launch, the cache suddenly purges its keys, and the database instantly crashes under the thundering herd of traffic. What is this phenomenon called, and how do you mitigate it?

This is called a Cache Stampede (or Thundering Herd). It happens when a highly popular cached key expires.

#General DevOps #L2 #DevOps #SRE #Architecture
🎙️ Candidate Opening & Architectural Context
""When an interviewer asks about this scenario, I explain how we balanced incident response with long-term prevention. The interviewer is testing: Cache stampede, cache penetration/misses, jitter.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's PostgreSQL Database Administration & High Availability Course covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: "When an interviewer asks about this scenario, I explain how we balanced incident response with long-term prevention. The interviewer is testing: Cache stampede, cache penetration/misses, jitter.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."

1️⃣

Initial Diagnostics & Root Cause Analysis

This is called a Cache Stampede (or Thundering Herd). It happens when a highly popular cached key expires. Instantly, thousands of concurrent requests hit the cache, find a miss, and *all* of them simultaneously bypass the cache and query the database to regenerate the exact same data, crashing the database.

  • Adding Jitter: Instead of setting a strict 1-hour expiration on keys, add random jitter (e.g., 60 minutes + random 0 to 5 minutes) so keys expire staggeringly, preventing massive simultaneous purges.
  • Mutex Locks: When a cache miss occurs, the first thread acquires a distributed lock (e.g., Redis SETNX) for that specific key. It proceeds to query the database. The other 999 concurrent threads fail to get the lock, and sleep/poll for 50ms until the first thread populates the cache for them.
2️⃣

Remediation & Permanent Safeguards

Mitigation strategies:

💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Adding Jitter: Instead of setting a strict 1-hour expiration on keys, add random jitter (e.g., 60 minutes + random 0 to 5 minutes)."
⚡ 60-Second Elevator Pitch Talking Points
  • Adding Jitter: Instead of setting a strict 1-hour expiration on keys, add random jitter (e.g., 60...
  • Mutex Locks: When a cache miss occurs, the first thread acquires a distributed lock (e.g., Redis ...
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Applying exclusive-lock DDL table migrations on live production databases during peak traffic windows when configuring General Redis cache DDL migrations that acquire an exclusive table lock block all concurrent queries, queuing connections until the database connection pool exhausts.
  2. Allowing high-frequency queries to trigger full table scans without appropriate composite indexing when configuring General Redis cache Sequential table scans saturate database CPU and disk I/O, evicting frequently queried data from the buffer cache and causing cascading timeouts.
  3. Disabling referential integrity constraints during bulk ETL imports without post-import consistency validation when configuring General Redis cache Skipping relational consistency checks risks introducing orphaned records and referential integrity violations into production tables.
  4. Relying on database snapshot backups that have never been verified through automated restoration drills when configuring General Redis cache Backups that have never been tested with automated restore verification frequently fail during real disaster recovery scenarios.
Advertisement
Want more Databases & Storage scenarios?
Explore our complete collection of scenario-based Databases & Storage interview runbooks.
Browse All Databases & Storage Questions →