In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what redis avalanche refers to, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
What is an avalanche?
Because the cache layer carries a large number of requests, which effectively protects the storage layer, but if the cache cannot provide service as a whole for some reason, then all requests will reach the storage layer, and the amount of invocation of the storage layer will soar, causing the storage layer to die. The English interpretation of cache avalanche is a fleeing bison, which means that after the cache layer is pawned, concurrent traffic will access the back-end storage in large quantities like a galloping bison.
The popular and simple understanding of cache avalanche is: due to the invalidation of the original cache (or the data has not been loaded into the cache), all requests that should have accessed the cache have gone to query the database during the absence of the new cache (the cache is normally obtained from Redis, as shown below), which will cause great pressure on the database CPU and memory, which will seriously cause database downtime and system crash.
When the cache expires, it is shown below:
A scenario with this problem is when the cache server is restarted or a large number of caches fail in a certain period of time, so that in the event of failure, a large amount of data will directly access the DB, which puts great pressure on the DB.
The avalanche effect of cache failure has a terrible impact on the underlying system! Is there any way to solve this problem?
Solution method
1) set the high availability of redis cluster and DB cluster. If the redis goes down, it can be replaced by another machine immediately. This prevents some of the risks.
2) use mutexes
After the cache expires, the number of threads reading and writing to the database is controlled by locking or queuing. For example, only one thread is allowed to query data and write cache for a key, while other threads wait. In the case of a stand-alone machine, you can use synchronized or lock to solve the problem. In a distributed environment, you can use the setnx command of redis to solve the problem.
3) different key can be set for different expiration time, so that the cache expiration time is different and the average distribution can be achieved as far as possible.
4) never expire
The setting in redis does not expire forever, which ensures that there will be no hot issues, that is, it will not expire physically.
5). Resource protection
Using netflix's hystrix, you can do thread pool isolation for various resources, thereby protecting the main thread pool.
Thank you for reading this article carefully. I hope the editor can share what redis Avalanche refers to is helpful to everyone. At the same time, I also hope that you can support us, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.