English 中文(简体)
Redis - Pipelining
  • 时间:2024-12-27

Redis - Pipepning


Previous Page Next Page  

Redis is a TCP server and supports request/response protocol. In Redis, a request is accomppshed with the following steps −

    The cpent sends a query to the server, and reads from the socket, usually in a blocking way, for the server response.

    The server processes the command and sends the response back to the cpent.

Meaning of Pipepning

The basic meaning of pipepning is, the cpent can send multiple requests to the server without waiting for the reppes at all, and finally reads the reppes in a single step.

Example

To check the Redis pipepning, just start the Redis instance and type the following command in the terminal.

$(echo -en "PING
 SET tutorial redis
GET tutorial
INCR 
visitor
INCR visitor
INCR visitor
"; sleep 10) | nc localhost 6379  
+PONG 
+OK 
redis 
:1 
:2 
:3 

In the above example, we will check Redis connection by using PING command. We have set a string named tutorial with value redis. Later, we get that keys value and increment the visitor number three times. In the result, we can see that all commands are submitted to Redis once, and Redis provides the output of all commands in a single step.

Benefits of Pipepning

The benefit of this technique is a drastically improved protocol performance. The speedup gained by pipepning ranges from a factor of five for connections to localhost up to a factor of at least one hundred over slower internet connections.

Advertisements