Pipelining sends multiple Redis commands in a single network round-trip instead of waiting for each command's reply before sending the next. It dramatically improves throughput when issuing many commands, because network latency — not Redis itself — is often the bottleneck.
The problem: round-trip latency
Normally each command is a request→reply round-trip:
send GET → wait for reply → send GET → wait for reply → ... (N × network latency)
→ Redis processes each command in microseconds, but each round-trip adds network
latency (e.g. 0.5ms). For 1000 commands, that's ~500ms JUST in waiting!
Pipelining: batch the commands
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
