Cache penetration, cache failure (cache avalanche) and cache concurrency

Source: Internet
Author: User

cache penetration : Usually the cache is based on key to find value, if the cache does not exist, then go to the db to find, if found, the Key->value write to the cache. However, for some of the data that does not exist in the cache each time to find, so every time to find in DB, DB can not find so can't write cache, so reciprocating, then lost the meaning of the cache.

WORKAROUND: The query is empty to db, but the cache expiration time of this data need to be set to a little bit; all possible data is hashed into a bitmap by the key, and the impossible data is filtered directly by the bitmap without querying db.

Cache failure (Cache avalanche): High concurrency, we also set the same expiration time for a large number of caches, causing a cache to fail at the same time, or the machine restart caused by the cache all the same time failure. This will allow a large number of requests to look at the db at the same time, causing great pressure on db.

Workaround: Control the number of threads reading DB, and randomly set the expiration time of the cache to avoid the simultaneous failure of large caches.

cache concurrency : high concurrency, multiple threads query to a cache failure (or the key does not cache), and go to DB to find and set the cache, caused by the pressure problem.

WORKAROUND: When the query to key is empty, lock, then check DB, update the cache, unlock.

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.