Reference: blog.csdn.net/a745233700/…

Cache penetration (not found)

Situation:

When users access data, they look in the cache first, not the databaseCopy the code

Question:

When a large number of users access the same data, because there is no cache in the database to obtain, to the database caused a huge pressure.Copy the code

Solution:

Select * from Redis; select * from Redis; select * from Redis; select * from Redis; select * from Redis; You don't need to query the database anymore.Copy the code

Cache breakdown (single key expired)

Question:

When a hot key fails, a large number of users directly access the database, resulting in a sharp increase in database pressureCopy the code

Solution:

1. Set the hotspot data to never expire. 2Copy the code

Cache avalanche (large number of keys expired)

Question:

A large amount of data in the cache expires or Redis goes down at the same time, resulting in a large number of database accesses and increased stressCopy the code

To solve

1. Traffic limiting degradation - Locking controls the number of threads in the write cache. 2. Data preheating - Cache data to Redis in advance to evenly distribute expiration time 3. Redis high availability - Remote liveCopy the code