Open In App

Redis Pipelining

Redis is a Transmission Control Protocol (TCP) server which supports request or response protocol. A request is completed in 2 steps :

What is Pipelining : In pipelining, client can send multiple queries or requests to server without waiting for all replies of queries at all and can finally reads replies in single go. In pipelining, client needs reply of read command and then it can call write command.



Advantages of Redis Pipelining : The main advantage of Redis pipelining is to boosting up protocol performance. It improves Redis performance because of multiple commands simultaneous execution. The speedup gained by pipelining ranges from factor of 5 for connections to localhost up to factor of at least 100 over low speed internet connections. 

Example : 
Let’s take scenario where we will submit multiple commands to Redis one time and then it will provide output of all commands in one go. 



Open Redis terminal and put the following command : 

(echo -en “PING\r\n SET master geeksforgeeks\r\n GET master\r\n INCR visitor\r\n INCR visitor\r\n INCR visitor\r\n”; sleep 15) |   
nc localhost 6876   

Output: 

1st Run: 
$(echo -en “PING\r\n SET master geeksforgeeks\r\n GET master\r\n INCR visitor\r\n INCR visitor\r\n INCR visitor\r\n”; sleep 15) |

nc localhost 6876  
+PONG 
+OK 
geeksforgeeks
:5 
:6 
:7 

2nd Run: 
$(echo -en “PING\r\n SET master geeksforgeeks\r\n GET master\r\n INCR visitor\r\n INCR visitor\r\n INCR visitor\r\n”; sleep 15) |

nc localhost 6876  
+PONG 
+OK 
geeksforgeeks
:8 
:9 
:10

Note :

Article Tags :