Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pipelining vs transaction in redis

When we use a transaction in Redis, it basically pipelines all the commands within the transaction. And when EXEC is fired, then all the commands are executed together, thus always maintaining the atomicity of multiple commands.

Isn't this same as pipelining?

How are pipelining and transaction different? Also, why does not the single threaded nature of Redis suffice? Why do we explicitly need pipelining/transaction?

like image 451
Manas Saxena Avatar asked Mar 29 '15 09:03

Manas Saxena


People also ask

What is Pipelining in Redis?

Redis pipelining is a technique for improving performance by issuing multiple commands at once without waiting for the response to each individual command. Pipelining is supported by most Redis clients.

What is transaction in Redis?

Redis Transactions allow the execution of a group of commands in a single step, they are centered around the commands MULTI , EXEC , DISCARD and WATCH . Redis Transactions make two important guarantees: All the commands in a transaction are serialized and executed sequentially.

Which among the following is a benefit of pipelining in Redis?

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.

How many commands can be sent to a server in pipelining Redis?

In most cases, limiting the size of the pipeline to 100-1000 operations gives the best results. But, you can do a little benchmark research that includes typical requests that you send.


1 Answers

Pipelining is primarily a network optimization. It essentially means the client buffers up a bunch of commands and ships them to the server in one go. The commands are not guaranteed to be executed in a transaction. The benefit here is saving network round trip time for every command.

Redis is single threaded so an individual command is always atomic, but two given commands from different clients can execute in sequence, alternating between them for example.

Multi/exec, however, ensures no other clients are executing commands in between the commands in the multi/exec sequence.

like image 174
The Real Bill Avatar answered Sep 25 '22 23:09

The Real Bill