In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
I believe many inexperienced people are at a loss about what Redis cache traversal is, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
First, cache penetration (breakdown)
Principle: cache penetration (breakdown) refers to querying a data that must not exist, because the cache is passively written when the cache is not hit, and for fault tolerance, if the data cannot be found from the storage layer, it will not be written to the cache. This will cause this non-existent data to query to the storage layer every time, losing the meaning of the cache. When the traffic is high, the pressure on the database increases sharply (there may be downtime).
Solution:
1. Bloom filter
All possible query parameters are stored in the form of hash, checked in the control layer first, and discarded if they do not match. And the most common is to use a Bloom filter to hash all possible data into a large enough bitmap, and a certain non-existent data will be intercepted by this bitmap, thus avoiding the query pressure on the underlying storage system.
two。 Cache empty object
If the data returned by a query is empty (whether the data does not exist or a system failure), we still cache the empty result, but its expiration time will be very short, no more than five minutes.
First, null values are cached, which means that more keys are stored in the cache layer and more memory space is needed (if it is an attack, the problem is more serious). A more effective way is to set a shorter expiration time for this kind of data (the longest is no more than five minutes) and let it be removed automatically.
Second, the data in the cache layer and the storage layer will be inconsistent for a period of time, which may have a certain impact on the business. For example, if the expiration time is set to 5 minutes, if this data is added to the storage layer, there will be inconsistency between the cache layer and the storage layer data during this period of time. At this time, you can use the message system or other means to clear the empty objects in the cache layer.
Second, cache avalanche
Principle: cache avalanche is when caching is concentrated in a certain period of time and fails at the same time, all requests are forwarded to the database, and excessive instantaneous pressure in the database leads to avalanche effect.
Solution:
1. Lock queue
After the cache expires, the number of threads reading the database write cache 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.
two。 Increase random value of cache time
Add a random value to the original expiration time, such as 1-5 minutes random, so that the repetition rate of each cache expiration time will be reduced, and it is difficult to cause collective failure events.
Third, cache warm-up
The new cache system does not have any cached data, and the system performance and database load are not very good in the process of cache reconstruction, so it is best to load the hot data to be cached into the cache before the system goes online. This cache preloading method is cache preheating.
4. Cache hot backup
Cache hot backup means that when a cache server is not available, it can be switched to a backup cache server in real time without affecting the cache usage. In cluster mode, each master node has one or more slave nodes as a backup. Once the master node is hung up, the slave node immediately acts as the master node.
After reading the above, have you mastered the method of Redis cache traversal? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.