From bf8de44ea8f1481e7e3b0035cbb471d69294d2ee Mon Sep 17 00:00:00 2001 From: Rueian Date: Sun, 3 Nov 2024 11:10:09 -0800 Subject: [PATCH] docs: add a note about DisableAutoPipelining Signed-off-by: Rueian --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0211fdac..59b9ce16 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ To reuse a command, use `Pin()` after `Build()` and it will prevent the command ### Auto Pipelining -All concurrent non-blocking redis commands (such as `GET`, `SET`) are automatically pipelined, +All concurrent non-blocking redis commands (such as `GET`, `SET`) are automatically pipelined by default, which reduces the overall round trips and system calls and gets higher throughput. You can easily get the benefit of [pipelining technique](https://redis.io/docs/manual/pipelining/) by just calling `client.Do()` from multiple goroutines concurrently. For example: @@ -99,6 +99,12 @@ Benchmark source code: https://github.com/rueian/rueidis-benchmark A benchmark result performed on two GCP n2-highcpu-2 machines also shows that rueidis can achieve higher throughput with lower latencies: https://github.com/redis/rueidis/pull/93 +### Disable auto pipelining + +While auto pipelining maximizes throughput, it relys on additional goroutines to process requests and responses and may add some latencies due to goroutine scheduling and head of line blocking. + +You can avoid this by setting `DisableAutoPipelining` to ture, then it will switch to connection pooling approach and serve each request with dedicated connection on the same goroutine. + ### Manual Pipelining Besides auto pipelining, you can also pipeline commands manually with `DoMulti()`: