Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do Redis clients implement pipelining?

Tags:

redis

In the Redis protocol documentation it states:

A client can use the same connection in order to issue multiple commands. Pipelining is supported so multiple commands can be sent with a single write operation by the client, it is not needed to read the server reply in order to issue the next command. All the replies can be read at the end.

However, I can't find any example of how this is actually implemented. How does a Redis client implement pipelining?

like image 723
TaylorOtwell Avatar asked Oct 28 '11 13:10

TaylorOtwell


1 Answers

Just throwing in some more insights to the above answers. One way to understand redis pipeline is to understand the fact that redis pipeline is completely a client side implementation and the redis server has nothing to do with it. While this differs among different client implementation, here's the generalized idea:

Pipelining is aimed at solving response latency issues in high network latency environments. So, the lesser the amount of time spent over the network in sending commands and reading response, the better. This is effectively achieved by buffering. The client may (or may not) buffer the commands at the TCP stack (as mentioned in other answers) before they are sent to the server. Once they are sent to the server, the server executes them and buffers them on the server side. Unlike the usual case where the client reads the response as soon as the response is received, in case of pipelining, the client reads the responses form the server-side buffer in parts or when the application executes 'sync' (close the pipeline). This is advantageous because the time spent over the network by the client in reading the responses is far lesser.

Here's a post on my blog which you may refer to get a better idea: http://nachivpn.blogspot.in/2014/11/redis-pipeline-explained.html

like image 151
nachi Avatar answered Sep 29 '22 12:09

nachi