Blocking:
Redis is a typical single-threaded architecture that can be a nightmare for our applications if blocking occurs. The scenarios that cause blocking are broadly divided into intrinsic and extrinsic causes.
Intrinsic reason: Unreasonable use of API or data structure, CPU saturation, persistent blocking, etc.
External reasons: CPU competition, memory exchange, network problems, etc.;
The following two reasons are analyzed separately:
- Unreasonable use of API or data structure:
- For example, the execution speed of hgetall, such as the high data volume and the command algorithm complexity is O (n), is bound to be very slow, and the command to avoid using the algorithm complexity more than O (n) in the highly concurrent scenario wins.
- Redis Native provides a slow query statistics function, execute slowlog get {n} can get the most recent n slow query command, default more than 10ms will be recorded in the fixed-length queue, the online recommendation is set to 1ms.
- Modify the low-algorithm command, disable keys, sort, and so on, and resize the large object: Prevents too much data from being manipulated at one command. (Execution Redis-cli-h{ip}-p{port} Bigkeys can scan out large objects);
- CPU saturation:
Redis Supplements (Fri)