Redis › Redis Performance Tuning & Benchmarking
What is pipelining, and how does it improve throughput when performing many operations against Redis?
BeginnerAnswer
Pipelining lets you send multiple commands to Redis together without waiting for a response after each individual one, dramatically reducing the impact of network round trip time when performing many operations, since you only wait for all the responses to come back together at the end rather than one at a time.
-- Without pipelining: many separate round trips
-- With pipelining: commands batched into fewer round trips
pipe = redis.pipeline()
for i in range(1000):
pipe.set(f'key{i}', f'value{i}')
pipe.execute()Real-world example A data migration script uses pipelining to insert one hundred thousand records into Redis, completing significantly faster than it would have by sending each individual command as a separate network round trip.