Cache penetration, Cache breakdown, Cache avalanche Concepts and solutions

Source: Internet
Author: User
Cache penetration 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.

Solution Solutions

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

Access key does not query the value in db, also writes null values to the cache, but can set a shorter expiration time.

Cache Avalanche 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.

Solution Solutions

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 Concept

An existing key, at the moment the cache expires, there are a large number of requests, these requests will penetrate into the db, resulting in a large number of instantaneous DB requests, pressure surges.

Solution Solutions

Before accessing the key, use SETNX (set if not exists) to set another short-term key to lock the access of the current key, and then delete the short-term key at the end of the visit.

Cache penetration, Cache breakdown, Cache avalanche Concepts and solutions

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.