Pipelining gửi nhiều lệnh Redis trong một round-trip mạng đơn lẻ thay vì chờ reply của từng lệnh trước khi gửi lệnh tiếp theo. Nó cải thiện throughput đáng kể khi phát ra nhiều lệnh, vì độ trễ mạng — không phải Redis — thường là nút thắt cổ chai.
Vấn đề: độ trễ round-trip
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: gom batch các lệnh
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
