Home » Redis Pipelining

Redis Pipelining

Before knowing pipelining, first know the concept of Redis:

Redis is a TCP server which supports request/response protocol. In Redis, a request is completed in two steps:

  • The client sends a query to the server usually in a blocking way for the server response.
  • The server processes the command and sends the response back to the client.

What is Pipelining

Pipelining facilitates a client to send multiple requests to the server without waiting for the replies at all, and finally reads the replies in a single step.

Example

Let’s see an example of Redis pipelining. In this example, we will submit multiple commands to Redis once and Redis will provide the output of all commands in a single step.

Open Redis terminal and use the following command:

Redis pipelining 1

Here:

  • PING command is used to check Redis connection.
  • A string is set named “sssit” having a value “javatraining”.
  • Got the key values and incremented the visitors numbers three times.

You can see that every time the value is incremented.


Advantage of Pipelining

The main advantage of Redis pipelining is speeding up the Redis performance. It drastically improves the protocol performance because of multiple commands simultaneous execution.

Pipelining vs Scripting

Redis Scripting is available in Redis version 2.6 or greater. A lot number of use cases for pipelining can be addressed more efficiently using scripts that perform a lot of the work needed at the server side.

The main advantage of scripting is that it can both read and write data with minimal latency. It makes operations like read, compute, write very fast.

On the other hand, pipelining doesn’t use this scenerio. In pipelining, the client needs the reply of the read command before it can call the write command.

Next TopicRedis Partitioning

You may also like