Sihai network

Redis avalanche and penetration solutions

Redis penetration means that when the key queried by the user does not exist in redis and the corresponding ID does not exist in the database, it is attacked by illegal users. A large number of requests will be directly hit on the DB, causing downtime and affecting the whole system. Solution: cache empty data, such as empty string, empty object, empty array or list.

Redis avalanche means that a large number of data in the cache fails, and then a large number of requests come in. However, because all keys in redis fail, all requests will be sent to DB, resulting in downtime. Solution: set the corresponding hotspot key to never expire. The expiration time is staggered. The expiration time is generated randomly, and the expiration time of hot data can be set longer, and that of non hot data can be set shorter. Multi cache combination, for example, when a request enters, you can request redis now. When redis does not exist, you can request Memcache again. If you do not request DB again. (redisXueBengHeChuanTouDeJieJueFangFa)