当前位置:网站首页>A complete tutorial for getting started with redis: Pipeline
A complete tutorial for getting started with redis: Pipeline
2022-07-04 22:53:00 【Gu Ge academic】
3.3.1 Pipeline Concept
Redis The client execution of a command is divided into the following four processes :
1) dispatch orders
2) Order to line up
3) Command execution
4) Return results
among 1)+4) be called Round Trip Time(RTT, Round trip time ).
Redis Batch operation commands are provided ( for example mget、mset etc. ), Save effectively RTT. but
Most commands do not support batch operations , For example, to perform n Time hgetall command , did not
mhgetall Command exists , Need to consume n Time RTT.Redis The client and server of may be deployed in different places
On the same machine . For example, the client is in Beijing ,Redis The server is in Shanghai , The straight-line distance between the two places is about
1300 km , that 1 Time RTT Time =1300×2/(300000×2/3)=13 millisecond ( Light in a vacuum
The transmission speed is per second 30 Thousands of kilometers , Let's say the fiber is at the speed of light 2/3), So the client is 1 second
Can only be carried out in about 80 The next order or so , This and Redis The high concurrency and high throughput of
Chi .
Pipeline( Assembly line ) The mechanism can improve the above problems , It can combine a group of Redis Order to enter
Row assembly , Through a RTT Transferred to the Redis, Will this group again Redis The execution results of commands are in order
Return to the client , chart 3-5 Is not used Pipeline Yes n Bar command , The whole process needs n Time
RTT.

chart 3-6 For the use of Pipeline Yes n subcommand , The whole process needs 1 Time RTT.
Pipeline It's not a new technology or mechanism , Many technologies have been used . and RTT
In different network environments, there will be different , For example, the machine room and the same machine will be faster , Cross machine room and cross region
It will be slow .Redis The actual execution time of the command is usually at the microsecond level , That's why there is Redis sex
The bottleneck is the network .
redis-cli Of --pipe Option is actually using Pipeline Mechanism , For example, the following operation will set
hello world and incr counter Two commands assemble :
echo -en '*3\r\n$3\r\nSET\r\n$5\r\nhello\r\n$5\r\nworld\r\n*2\r\n$4\r\nincr\r\
n$7\r\ncounter\r\n' | redis-cli --pipe
But most developers prefer to use... In high-level language clients Pipeline, At present, the
part Redis All clients support Pipeline, The first 4 In chapter, we will introduce how to pass Java Of Redis customer
Home end Jedis Use Pipeline function .
3.3.2 Performance testing
surface 3-1 The non Pipeline and Pipeline perform 10000 Time set operation
The effect of , Two conclusions can be drawn as follows :
·Pipeline Execution speed is generally faster than item by item execution .
· The greater the network delay between the client and the server ,Pipeline The more obvious the effect of .

Due to the different test environment, the specific number may be different , This test Pipeline Carry... Every time
belt 100 Bar command .

3.3.3 Native batch command and Pipeline contrast
have access to Pipeline Simulate the effect of batch operation , But when using it, we should pay attention to its relationship with the original
The difference between generating batch commands , It includes the following points :
· The native batch command is atomic ,Pipeline It's non atomic .
· A native batch command is a command that corresponds to multiple key,Pipeline Supports multiple commands .
· The native batch command is Redis The server supports the implementation of , and Pipeline The server and the customer are required
The common implementation of the end .
3.3.4 Best practices
Pipeline Although easy to use , But every time Pipeline The number of assembly commands cannot be unlimited , no
One time assembly Pipeline Too much data , On the one hand, it will increase the waiting time of the client , The other side
It can cause a certain amount of network congestion , It's possible to put a Pipeline Split into multiple
smaller Pipeline To complete .
Pipeline Only one can be operated Redis example , But even in distributed Redis Scene , Can also be
As an important optimization means of batch operation , For details, see page 11 Chapter .
边栏推荐
- The Sandbox 和数字好莱坞达成合作,通过人力资源开发加速创作者经济的发展
- Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
- Common methods in string class
- Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
- 攻防世界 MISC 进阶区 hong
- 蓝队攻防演练中的三段作战
- Business is too busy. Is there really no reason to have time for automation?
- Redis入门完整教程:GEO
- Attack and defense world misc advanced grace-50
- 攻防世界 MISC 进阶区 can_has_stdio?
猜你喜欢

串口数据帧

Unity-VScode-Emmylua配置报错解决

Breakpoint debugging under vs2019 c release
[the 2023 autumn recruitment of MIHA tour] open [the only exclusive internal push code of school recruitment eytuc]

Google Earth Engine(GEE)——Tasks升级,实现RUN ALL可以一键下载任务类型中的所有影像
How to send a reliable request before closing the page

Logo Camp d'entraînement section 3 techniques créatives initiales

Set up a website with a sense of ceremony, and post it to 1/2 of the public network through the intranet

LOGO特訓營 第三節 首字母創意手法

Persistence mechanism of redis
随机推荐
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Common methods in string class
Practice and principle of PostgreSQL join
Detailed explanation of heap sort code
Attack and defense world misc advanced area ditf
Business is too busy. Is there really no reason to have time for automation?
环境加密技术解析
模拟摇杆控制舵机
Prosperity is exhausted, things are right and people are wrong: where should personal webmasters go
[OpenGL] note 29 anti aliasing (MSAA)
[machine learning] handwritten digit recognition
Advanced area a of attack and defense world misc Masters_ good_ idea
新版判断PC和手机端代码,手机端跳转手机端,PC跳转PC端最新有效代码
How can enterprises cross the digital divide? In cloud native 2.0
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
PMO: compare the sample efficiency of 25 molecular optimization methods
攻防世界 MISC 高手进阶区 001 normal_png
Redis入门完整教程:初识Redis
How to reset the password of MySQL root account
攻防世界 MISC 進階區 Erik-Baleog-and-Olaf