What is Cache penetrate? How to avoid? What is Cache avalanche? How to avoid?

Cache penetration

  General caching system, it is in accordance with the key to cache query, if the corresponding value does not exist, they should go to find the back-end systems (such as DB). Some deliberately malicious request query key is not present, a large amount of the request, it will cause a lot of pressure on the back-end systems. This is called caching penetration.

How to avoid?

   1: the case where an empty result set also caching and set shorter, or the data key corresponding to the dirty cache after the insert.

   2: is not present on certain key filtered. We can put all the possible key into a large Bitmap by the bitmap filter query.

 

Cache avalanche

  When the cache server reboot or a large number of cache concentrated in one time period fail, so that when failure, back-end systems will bring a lot of pressure. Cause the system to crash.

How to avoid? 

   1: After a cache miss, by locking to control the number of threads or queue database read write cache. For example, a key for allowing only one thread to query the data and write cache, other threads wait.

   2: Make secondary cache, cache the original A1, A2 copy is cached, when A1 fails, access to A2, A1 cache expiration time is set short-term, A2 is set for long-term

   3: a different key, to set different expiry time for the point in time of a cache miss as uniform as possible

  

  Welcome to the Internet technology exchange group common learning and common progress

  

Guess you like

Origin www.cnblogs.com/lengxuanwl/p/12152850.html