Pipelining ส่งหลายคำสั่ง Redis ใน network round-trip เดียว แทนที่จะรอ reply ของแต่ละคำสั่งก่อนส่งคำสั่งถัดไป มันเพิ่ม throughput อย่างมากเมื่อออกคำสั่งจำนวนมาก เพราะ network latency — ไม่ใช่ Redis เอง — มักเป็นคอขวด
ปัญหา: latency ของ 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: batch คำสั่ง
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
