advancedTop 30 Scenario-Based Questions
How do you prevent a cache avalanche in production?
Cache avalanche: many keys expire simultaneously → DB flooded. Prevention: 1) Randomize TTL: don't set uniform TTL. Instead of TTL=3600, use TTL = 3000 + random(0,600). Keys expire spread over 10 minutes instead of all at once. 2) Eternal cache + async refresh: never expire critical keys. Background job proactively refreshes before data is too stale. 3) Circuit breaker on DB: if DB load spikes (av
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response