Avalanche penetration of Redis

Avalanche
Cause: When the key values ​​stored in the cache expire collectively at the same time, a large number of requests go past the cache to directly access the database. The database cannot withstand such a large number of accesses, resulting in downtime

solution:

  • When setting the expiration time for the key value, set a random value for the time to avoid all key values ​​becoming invalid at the same time
  • Set hotspot data to never expire

Penetration
Reason: A large number of values ​​that do not exist in the database are accessed. For example, only id is 1 in the database, and a large number of people visit id = -1, which causes excessive pressure on the database and may also overwhelm the database

solution:

  • Check directly at the interface layer to prohibit illegal data requests

Breakdown
reason: A hot key value just expired when it was subjected to a large number of access requests, and data access operations poured into the database, causing database downtime. PS: Unlike an avalanche, an avalanche is a large area of ​​key value failure at the same time Caused, breakdown is that a hot key is overwhelmed by a large number of accesses at the moment of failure.

solution:

  • The data that cannot be retrieved from the cache is not retrieved in the database. At this time, you can also write the value of the corresponding Key as a null value and set it to a short-term expiration time, such as 30 seconds.
  • For people who visit the same ip address multiple times, block processing through the gateway

to sum up

All are caused by high concurrent data access operations. Under normal circumstances, redis is still able to resist. Specific analysis of specific matters

There is something wrong in the article, please remind me in time, thank you

Guess you like

Origin blog.csdn.net/smokebai/article/details/109757915