Skip to content
Related Articles

Related Articles

Redis Pipelining

View Discussion
Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 20 Jul, 2022

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

  • The client sends query to server in blocking manner to get server response.
  • Then server operates command and sends response back result of query to client.

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 :

  • PING command is used to check connection of redis.
  • A string is set named “master” having value “geeksforgeeks”.
  • Got the key value and incremented visitors numbers 3 times.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!