How to Stop Redis Cache Penetration, Avalanche, and Breakdown

This article explains the three major Redis cache issues—penetration, avalanche, and breakdown—detailing their causes, real‑world examples, and practical mitigation strategies such as caching null values, using Bloom filters, staggering TTLs, multi‑level caching, and lock mechanisms to protect database stability.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Stop Redis Cache Penetration, Avalanche, and Breakdown

Key Concepts

Cache penetration occurs when many requests query keys that do not exist; cache avalanche happens when a large number of keys expire simultaneously; cache breakdown (or stampede) occurs when a hot key expires while many users request it.

Solutions for Cache Penetration

Cache null values (e.g., store key with value null and a short TTL).

Set whitelist/blacklist to block malicious IDs.

Use a Bloom filter (or BitMap) to pre‑filter valid keys before hitting Redis.

Apply network‑level protection such as firewalls.

Solutions for Cache Avalanche

Stagger key expiration times by adding random offsets to TTL.

Monitor hot data and adjust TTL in real time.

Use lock mechanisms to serialize DB fallback when a cache miss occurs.

Employ multi‑level caching (NGINX cache, Redis, other caches) for higher reliability.

Mark cache status and refresh expired keys asynchronously.

Solutions for Cache Breakdown

Pre‑warm hot data in cache before it becomes popular.

Continuously monitor hot keys and dynamically adjust their TTL.

Use locks to prevent a thundering‑herd effect when the hot key is missing.

The root cause of all three scenarios is a drop in Redis hit rate, causing requests to fall back to the database, which can quickly become overloaded.

Additional precautions: set appropriate TTL for null entries, combine blacklist with firewall rules, and be aware of Bloom filter false‑positive possibilities.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendCacheRediscache avalanchecache breakdowncache penetration
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.