The Round Trip Tax
Each Redis command is fast, but the network round trip dominates when latency is high. Send one command, wait for the reply, send the next, and a thousand commands mean a thousand round trips. Even at one millisecond each, that is a full second of mostly waiting.
Pipelining
Pipelining sends many commands without waiting for each reply, then reads all the replies together. The commands still execute in order on the server, but the client pays the round trip cost once for the whole batch.
- Throughput can jump several fold on a high latency link.
- The server queues replies, so the client must read them all.
- Memory matters: a giant pipeline buffers many replies, so batch in reasonable chunks.
Pipelining Is Not a Transaction
Pipelining only batches transport. Commands are not atomic as a group, and other clients commands can interleave between them. If you need atomicity, wrap the batch in MULTI and EXEC, or use a Lua script. Pipelining and transactions can even be combined.
When To Use It
Reach for pipelining whenever you issue many independent commands in a tight loop, such as bulk loading keys or fetching many values, and the commands do not depend on each other's results.
Key idea
Pipelining sends a batch of commands without waiting per reply, paying the round trip cost once for big throughput gains, but it does not make the batch atomic.