Pipelining invia più comandi Redis in un singolo round-trip di rete invece di attendere la risposta di ogni comando prima di inviare il successivo. Migliora drammaticamente il throughput quando si emettono molti comandi, perché la latenza di rete — non Redis stesso — è spesso il collo di bottiglia.
Il problema: latenza 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: raggruppare i comandi
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
