Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the problem with Redis blocking?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

What is the problem with Redis blocking? Many people don't know much about it. In order to let everyone know more about the reasons for Redis blocking problem, I summarized the following contents for everyone and looked down together.

Redis is a single-threaded architecture where all operations are done in a single main thread. So once Redis blocks, it's a nightmare. Next, let's look at the blocking problem for Redis. How to investigate and resolve.

Unreasonable use of Redis data structure or API

Large objects exist and complex higher commands are given to large objects

1. Perform hgetall or del operations on a hash with ten million elements. Such operations will cause Redis blocking

2. For such large objects, you can use redis-cli -h {host} -p {port} bigkeys to view them. However, this command can only query a type for its

The biggest key. If you want to query more than one. This can be done by modifying the redis-cli source code (Redis source code is C). If you don't want to modify the source code, you can also use scan to do so.

Note the Scan command. This command can only scan data on a single Redis. If you are a cluster, you need to execute it once on each machine. However, if you use an open source client (e.g. Java's Letduce client), it will help you implement the scan command to scan the entire cluster.

3. Then split the large object. The exact split depends on the business.

Redis CPU usage is close to 100%.

1. Slave synchronizes host data. The slave receives the rdb file and loads the data from disk

2. Master-slave persistent data.

3, CPU utilization rate will reach 100%, it is possible that the real business access is really large. Redis handles 60,000 + requests per second. At this point, you can only do horizontal expansion

If Redis has only a few hundred or thousands of operands per second, and the CPU is still very high, it is possible to use commands with high algorithm complexity. For example, hgetall. There is also a possibility that memory is over-optimized. This situation has not been encountered for the time being, but it is also considered.

CPU competition

Redis is a CPU-intensive application and is not suitable for deployment with other CPU-intensive services.

In a production environment, the configuration of one of our servers is a 32-core logical CPU and 256GB of memory. Deploying only one Redis per machine would be wasteful. So it is possible to deploy multiple Redis on a single machine. Redis processes are usually bound to the CPU. However, when an RDB file or an AOF persistence is generated, child processes are spawned. This creates CPU competition with the parent process. So when persistence or master is turned on. CPU binding is not recommended

memory swap

Redis is an in-memory database where all data is stored in memory. So it is strongly recommended not to turn on memory swapping

network problems

If the delay of master-slave synchronization network is large, the slave will be disconnected and reconnected frequently. If it's been disconnected for too long. This will cause full synchronization when the slave is connected to the host again. At this time, both the host and slave will receive the influence.

The above is the details of what problem Redis blocking is caused by. Is there any harvest after reading it? If you want to know more, welcome to the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report