Home  >  Article  >  Database  >  How to solve redis cache avalanche

How to solve redis cache avalanche

藏色散人
藏色散人Original
2019-06-11 10:28:045314browse

How to solve redis cache avalanche

How to solve the redis cache avalanche?

Cache avalanche means that when we set the cache, we use the same expiration time, causing the cache to expire at the same time at a certain moment, all requests are forwarded to the DB, and the DB is under instantaneous pressure and avalanches.

Solution

The avalanche effect of cache invalidation has a terrible impact on the underlying system. Most system designers consider using locks or queues to ensure single-thread (process) writes to the cache, thereby preventing a large number of concurrent requests from falling on the underlying storage system in the event of a failure.

Here is a simple solution to spread out the cache expiration time. For example, we can add a random value to the original expiration time, such as 1-5 minutes randomly, so that the expiration time of each cache is The repetition rate will be reduced, making it difficult to cause collective failure.

Recommended: "Redis Video Tutorial"

The above is the detailed content of How to solve redis cache avalanche. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn