当前位置:网站首页>Redis notes (15) - Pipeline (the client packages and sends batch commands to save network overhead)
Redis notes (15) - Pipeline (the client packages and sends batch commands to save network overhead)
2022-06-26 09:46:00 【wohu1104】
Redis It's a client based - Server model and request / In response to the protocol TCP service . This means that normally a request follows these steps :
- The client sends a query request to the server , And monitor
Socketreturn , Usually in blocking mode , Waiting for the server to respond . - The server handles commands , And return the result to the client .
One client Through a socket Connection initiates multiple request commands .
After each request order is issued client Usually it will block and wait redis Service handling ,redis After processing the request command, the result will be returned to client .
The client and server connect through the network . Such a connection can be very fast , Or very slow ( Two hosts that can only be interconnected through multiple nodes on the WAN ). But whether there is network delay or not , Data packets are transmitted from the client to the server , And it takes some time for the client to get the corresponding information from the server . This period of time becomes the round trip delay ( Round Trip Time).
So when the client needs to execute a series of requests , It's easy to see the impact on performance ( For example, adding a large number of elements to the same queue , Or insert a large number of keys into the database ). If RTT The length of 250 millisecond ( In a WAN based low-speed connection environment ), Even if the server can handle 10 Million requests , But in fact, we can only process the most per second 4 A request .
If you are in a loop network ,RTT The duration is quite short ( My host ping 127.0.0.1 When it comes to 0.044ms), But if you execute a long list of write requests , It will be a little long .
1. The Conduit
A request / The corresponding services can be implemented as , Even if the client does not read the response of the old request , The server can still handle new requests . In this way , It can send multiple instructions to the server without waiting for the server to respond , And finally read all replies at once . The most significant advantage of pipeline technology is the improvement of redis Service performance .
adopt pipeline When there is a large number of operations . We can save a lot of time that we used to waste on network delay . It needs to be noted that pipeline Method pack command send ,redis The processing results of all commands must be cached before all commands are processed . The more orders to pack , The more memory the cache consumes . So it's not that the more orders you pack, the better . How much is appropriate depends on the situation .
If multiple instructions are executed consecutively , It will take multiple network packets back and forth . As shown in the figure below .
Adjust the reading and writing order , So that two consecutive write operations and two consecutive read operations will only take one network round trip in total , It's like continuous request The operation is combined , Successive response It's the same with operations .
This is the essence of pipeline operation , It's not a feature of the server , There's no difference at all between servers , Still got a message , Execute a message , The normal process of replying to a message . The client can save a lot by changing the reading and writing order of the instruction list in the pipeline IO Time , To improve performance .
边栏推荐
- CVPR:Refining Pseudo Labels with Clustering Consensus over Generations for Unsupervised Object Re-ID
- 点击遮罩层关闭弹窗
- "One week's work on Analog Electronics" - integrated operational amplifier
- 【CVPR 2021】Unsupervised Multi-Source Domain Adaptation for Person Re-Identification (UMSDA)
- 计算领域高质量科技期刊分级目录
- LeetCode 0710.黑名单中的随机数 - 预处理实现O(1)取值
- online trajectory generation
- Logical English structure [key points]
- Leetcode connected to rainwater series 42 (one dimension) 407 (2D)
- SQL advanced tutorial
猜你喜欢

kubernetes集群部署(v1.23.5)

Badge series 5: use of codecov

深度学习(初识tensorflow2.版本)之三好学生成绩问题(1)

十万行事务锁,开了眼界了。

【CVPR 2021】DatasetGAN: Efficient Labeled Data Factory with Minimal Human Effort

Detailed explanation of the network security competition questions (2) of the 2021 national vocational college skills competition (secondary vocational group)

Logview Pro can be used if the log is too large

【Sensors 2021】Relation-Based Deep Attention Network with Hybrid Memory for One-Shot Person Re-Id

"One week to finish the model electricity" - 55 timer

Summary of common commands of vim
随机推荐
MapReduce&Yarn理论
Creation and use of XSync synchronization script (taking debian10 cluster as an example)
Install new version cmake & swig & tinyspline
Thinkphp5 manual error reporting
The 100000 line transaction lock has opened your eyes.
Wechat official account reported error 10003
2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(1)详细解析教程
online trajectory generation
Origin of QPM
Redis 新手入门
深度学习(初识tensorflow2.版本)之三好学生成绩问题(1)
"One week to finish the model electricity" - 55 timer
Super data processing operator helps you finish data processing quickly
SQL 函数
Catalogue gradué de revues scientifiques et technologiques de haute qualité dans le domaine de l'informatique
LeetCode 958. 二叉树的完全性校验
Logical English structure [key points]
使用递归或while循环获取父/子层级结构的名称
Opencv depthframe - > pointcloud causes segmentation fault!
十万行事务锁,开了眼界了。