Cache breakdown, Cache penetration, cache avalanche

Source: Internet
Author: User


Reference article: Cache penetration, Cache breakdown, Cache avalanche concepts and solutions 


First. Cache Breakdown 

1. Concept


Cache breakdown refers to a high concurrency situation in the cache when the resource does not exist , causing the cache to miss, all requests penetrate into the backend database system to query, so that the database pressure is too large, Even the database service was crushed to death.


2. Solution
    1. Direct Lock: When the cache misses, the data is fetched from the database and updated into the cache;
    2. Timed task: Refresh the cache periodically;
    3. Multilevel cache: The first-level cache failure time is short, the two-level cache failure time is long, primary cache misses when the key lock, from the database to update the data to the cache and release the lock, the subsequent thread from the two-level cache to obtain data;

Second. The cache penetrates 

1. Concept


Access to a nonexistent key, the cache does not work, the request will penetrate into the DB, when the traffic is large, the db will be hung off.


2. Solution
    1. Using the bitmap filter, a large enough to store the key that may be accessed, the nonexistent key is filtered directly;

Third. Cache Avalanche 

1. Concept


A large number of keys set the same expiration time, resulting in the cache at the same time all failed, resulting in a large amount of instantaneous db requests, pressure surges, causing avalanches.


2. Solution


You can set the expiration time for the cache by adding a random value time, so that each key's expiration time is distributed, and will not fail at the same time.






Cache breakdown, Cache penetration, cache avalanche


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.