パイプライニングは、各コマンドの応答を待ってから次のコマンドを送信するのではなく、複数のRedisコマンドを単一のネットワークラウンドトリップで送信します。ネットワークレイテンシー(Redisそのものではなく)がボトルネックになることが多いため、多くのコマンドを実行する場合、スループットが劇的に向上します。
問題:ラウンドトリップレイテンシー
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!
パイプライニング:コマンドをバッチ化する
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
