Get the App
SLTechnology News&Howtos  ›  Database  › 

What problems may exist in Redis in the case of high concurrency

Shulou Source: shulou.com Published: 2022-06-01 01:59:25 09月29日 Update

This article shows you what problems Redis may have in the case of high concurrency, the content is concise and easy to understand, and can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Cache traversal:

When the user request parameter is param=zsan, the modified data null does not exist in the database, and the default null is not saved to Redis. In this case, a large number of malicious requests do not exist data, resulting in requests directly hitting the mysql database.

Solution:

When the param=zsan query is null, a copy is directly stored in redis, but this can only ensure that this data will not hit mysql next time. If malicious users randomly generate different parameters, they can still call mysql directly.

2. Cache avalanche:

Avalanche problems may occur when some caches in the cache expire almost at the same time in the same short period of time.

Solution:

1. Plan the expiration time of all caches in the system in advance

two。 Set the timeout time and add random numbers to avoid a large number of key failures at the same time

3. Hotspot caching

A user accesses the param=sex message when the key cache expires (is about to be saved from the database query to Redis). Suddenly, a large number of users request this key, resulting in data that has not yet been cached to the Redis and is requested to the mysql [hotspot cache may be triggered as long as the setting period is set)

Solution:

Double detection lock mechanism

The above is what problems Redis may have in the case of high concurrency. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Caching data time users problems methods databases situations content parameters malice skills hotspots knowledge avalanches queries differences concise concise and at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi Microsoft vpn Shulou Technology