Redis cache penetrating questions and avalanche problem?

Cache penetration : is the access key redis in a non-existent time, directly through the cache, queries to the database.

      If you are a hacker, when malicious attacks, each time over 2000 requests / second time, this time mysql basically hung up.

The solution is: per query from the database to a key that does not exist when you write a null value to the cache database, there is a time malicious attacks, taken directly from the cache to the null value.

 

 

 

Cache Avalanche : There is a 5000 request per second over time, redis library cache collapse, then these requests instantly fell on the mysql database, database direct result of the crash.

The solution is:

  Advance: library cache to improve the high availability, plus the use of master-slave structure Sentinel cluster clusters, 

  Things: Use ehcache + hystrix limiting component (when the request huge amount of time, they call themselves a downgrade to develop good hungry components, return some default values, such as Tips, or blank)

  Afterwards: do persistence, cache cluster recovery as soon as possible, once restored, the data is automatically read from the disk to restore data in memory.

 

Benefits 3: 2/5 as long as there is a request can be processed, it means that your system does not die, for the user is likely to click a few times to refresh the page does not come out, but probably several times more, will be flushed out once.

 

Guess you like

Origin www.cnblogs.com/qingmuchuanqi48/p/11117800.html