Cache stampede: Featured products slow to a crawl every 5 seconds
Cache stampede debugging lab. Traffic is flat, yet every five seconds the featured products endpoint stalls for everyone and the database pool saturates.
Practice debugging a cache stampede in a live, broken production system in your browser, with Redis and PostgreSQL. Find the root cause in the logs, terminal and code, fix it, and a load test checks that the fix holds under real traffic.
1. The Incident Context
You were paged at 02:14 because GET /products/featured keeps breaching its latency SLO. Traffic is flat, there has been no deploy, and Redis and Postgres both report healthy. The endpoint is fast most of the time, then about every five seconds it stalls for everyone at once.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
GET /products/featured on the checkout service, Redis key products:featured, Postgres products table.
- Behavior: Steady 150 req/s. Latency sits at a few milliseconds for several seconds, then p99 jumps to over 2 seconds. It recovers, and the cycle repeats on a regular rhythm of about 5 seconds.
- Error Rate: Mostly slow requests rather than errors, but during each spike some requests run out of time and fail.
- System Metrics: Postgres connection pool pinned at 5/5 with a long queue of waiting acquires during every spike. Postgres CPU climbs in bursts in step with the latency graph. Redis CPU and memory are flat.
3. Application Logs
2026/10/12 02:14:00 checkout service listening on :8080
# redis-cli monitor
02:14:05.002 "get" "products:featured"
02:14:05.002 "get" "products:featured"
02:14:05.003 "get" "products:featured"
02:14:05.218 "set" "products:featured" "[{\"id\":1,...}]" "ex" "5"
02:14:05.224 "set" "products:featured" "[{\"id\":1,...}]" "ex" "5"
02:14:05.231 "set" "products:featured" "[{\"id\":1,...}]" "ex" "5"
# k6
http_req_duration..............: avg=212ms p(95)=1.94s p(99)=2.18s
4. Your Objective
Step into the live environment while synthetic traffic is running, diagnose the root cause, and patch the codebase.
To clear this stack, your fix must satisfy these automated verification checks under a 60-second load test:
- Error Rate: Fewer than 1% of requests fail (
http_errors < 1%).
- Performance: P99 latency stays below 250 ms (
p99_latency_ms < 250).
- Data Integrity: All 20 products are still in the database (
data_integrity).
Toolbox: curl localhost:8080/products/featured, redis-cli ttl products:featured, redis-cli monitor, psql "$DATABASE_URL", htop. Save a file in the editor to rebuild and restart the app. Click Verify when you think it's fixed.
Your account and data
You can browse stacks without an account. To run labs you sign in with your email or Google account. BustedStack uses your email address to
sign you in, and your name and profile picture to show your account and pre-fill certificates. We never access your Gmail, contacts or Drive,
sell your data or run ad trackers.
Privacy Policy · Terms of Service · Browse stacks ·
hello@bustedstack.com
This site needs JavaScript to run labs.