当前位置:网站首页>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 .
边栏推荐
- 点击遮罩层关闭弹窗
- The first techo day Tencent technology open day, 628
- jz2440---使用uboot燒錄程序
- 我在中山,到哪里开户比较好?在线开户安全么?
- install ompl.sh
- [pulsar learning] pulsar Architecture Principle
- How to view the data mini map quickly and conveniently after importing data in origin
- 教你用shell脚本检测服务器程序是否在运行
- Jz2440--- using uboot burning program
- Badge series 8: generate a personalized Badge
猜你喜欢

【AAAI 2021】Few-Shot One-Class Classification via Meta-Learning 【FSOCC via Meta-learning】

测试须知——常见接口协议解析

安装 新版本cmake & swig & tinyspline

Construction practice of bank intelligent analysis and decision-making platform

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

How does flutter transfer parameters to the next page when switching pages?

Badge series 5: use of codecov

Record a time when the server was taken to mine

jz2440---使用uboot烧录程序

深度学习(初识tensorflow2.版本)之三好学生成绩问题(1)
随机推荐
Comprehensive interpretation! Use of generics in golang
工企专利匹配数据(数十万数据量)1998-2014年
How does flutter transfer parameters to the next page when switching pages?
A Style-Based Generator Architecture for Generative Adversarial Networks
install realsense2: The following packages have unmet dependencies: libgtk-3-dev
Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-ID
logback
"One week's work on digital power" -- encoder and decoder
install ompl. sh
LeetCode 剑指 Offer II 091.粉刷房子 - 原地修改
GAN Inversion: A Survey
点击遮罩层关闭弹窗
c语言语法基础之——局部变量及存储类别、全局变量及存储类别、宏定义 学习
Common SQL add / delete / modify query statements
mysql 数据库字段查询区分大小写设置
测试须知——常见接口协议解析
I am in Zhongshan. Where can I open an account? Is online account opening safe?
js---获取对象数组中key值相同的数据,得到一个新的数组
Introduction to QPM
【CVPR 2021】Unsupervised Multi-Source Domain Adaptation for Person Re-Identification (UMSDA)