Check a Cache for Stampede Risk
Added 2026-11-06
At expiration, every request hits the backend at once.
My system caches this data: [what, expiry policy, backend capacity]. Check stampede and avalanche risk: 1) find when and why hot keys expire together; 2) estimate concurrent load at expiry and whether the backend holds; 3) give three defenses — mutually exclusive rebuild, logical expiry with async refresh, randomized expiry — and when each fits; 4) design fallback and rate limiting for cache misses; 5) explain how warm-up and degradation fit in; 6) give the metrics — hit rate, origin QPS, rebuild time — and alert thresholds.
Site original
Chinese original
Replace these placeholders 1
Swap the bracketed parts for your own details before sending.
[what, expiry policy, backend capacity]
How to use
Estimate origin load at expiry before choosing a defense.
Try tweaking it
- Have it restate requirements and constraints before writing code.
- Ask for the smallest change plus a rollback path, not a full-file rewrite.
What you should get
- A minimal, runnable change with copy-ready code
- Impact list: which files and call sites must follow
Common mistakes
- Asking it to touch ten files at once, then losing track of what broke what.
- Pasting only the error, with no code or version, and getting an unfixable answer.
How to check the output
- The change runs, can be rolled back, and touches nothing unrelated.
- Edge cases (empty, oversized, concurrent) are covered or explained.
Where it works
- Good for: having it restate requirements and constraints, then propose the smallest runnable change.
- Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.