1、 What is pipline
Once network command time = once network transmission time (round trip) + once command execution time
2. Communication model of batch network command
N times of network command time = n times of network transmission time (round trip) + n times of command execution time
3. Pipline can pack n commands, transfer them to the server at one time, and then return the execution results in order
One pipline (n commands) network command time = one network transmission time (round trip) + n command execution time
The execution time of redis command is generally microseconds, which is very fast.
Therefore, network transmission is often the bottleneck of redis performance.
At this time, it is very important to save network transmission time.
2、 Comparison between pipline and native batch operation
1. Mget, Mset and other native batch operations
Batch operations such as mget and Mset are atomic operations
Pipline is a non atomic operation
3、 Suggestions for use
- Pay attention to the amount of data carried by pipline each time. The amount of data should not be too large
- Pipline can only work on one redis node at a time