为什么客户端连接数会影响Redis性能?
Why does the number of client connections affect Redis performance?
我一直在阅读 Redis 文档,但我不理解以下段落(来自 link http://redis.io/topics/benchmarks):
"Naively iterating on synchronous Redis commands does not benchmark Redis itself, but rather measure your network(or IPC) latency. To really test Redis, you need multiple connections and/or ..."
我做了以下测试以查看 1 个连接和 500 个连接之间的速度差异。正如我们所看到的,当只有 1 个连接时它会慢得多。但我不明白连接数为什么以及如何影响 Redis 速度性能。我是计算机网络新手,如有帮助将不胜感激!
$ redis-benchmark -c 500 -t ping
====== PING_INLINE ======
10000 requests completed in 0.10 seconds
500 parallel clients
3 bytes payload
keep alive: 1
$ redis-benchmark -c 1 -t ping
====== PING_INLINE ======
10000 requests completed in 0.19 seconds
1 parallel clients
3 bytes payload
keep alive: 1
当延迟 > 吞吐量时,您需要多个请求在运行中才能达到吞吐量的瓶颈,而不仅仅是往返延迟。
例如如果网络往返是 10 毫秒,那么客户端在发送另一个请求之前等待一个请求的结果在数学上限制为 100 个请求/秒。如果您的服务器可以处理更多,则无法使用单个客户端对其进行测试。
逻辑与网络上的常规数据传输相同,例如TCP window 大小。这篇 wiki 文章 (https://en.wikipedia.org/wiki/Bandwidth-delay_product) 可能有助于阐明需要保持多个数据包/操作在运行中的概念。对于 redis 请求,总延迟包括处理时间 + 网络时间。如果你在这方面遇到瓶颈,你将无法使服务器 CPU(或网络)保持 100% 繁忙。
请注意,实现 Instruction-Level Parallelism in a CPU 也是相同的概念。 (例如,要对一组浮点数求和,如果 FP add 具有 3 个周期延迟和每 1c 吞吐量一个,即完全流水线化,则您应该至少使用 3 个累加器)。
我一直在阅读 Redis 文档,但我不理解以下段落(来自 link http://redis.io/topics/benchmarks):
"Naively iterating on synchronous Redis commands does not benchmark Redis itself, but rather measure your network(or IPC) latency. To really test Redis, you need multiple connections and/or ..."
我做了以下测试以查看 1 个连接和 500 个连接之间的速度差异。正如我们所看到的,当只有 1 个连接时它会慢得多。但我不明白连接数为什么以及如何影响 Redis 速度性能。我是计算机网络新手,如有帮助将不胜感激!
$ redis-benchmark -c 500 -t ping
====== PING_INLINE ======
10000 requests completed in 0.10 seconds
500 parallel clients
3 bytes payload
keep alive: 1
$ redis-benchmark -c 1 -t ping
====== PING_INLINE ======
10000 requests completed in 0.19 seconds
1 parallel clients
3 bytes payload
keep alive: 1
当延迟 > 吞吐量时,您需要多个请求在运行中才能达到吞吐量的瓶颈,而不仅仅是往返延迟。
例如如果网络往返是 10 毫秒,那么客户端在发送另一个请求之前等待一个请求的结果在数学上限制为 100 个请求/秒。如果您的服务器可以处理更多,则无法使用单个客户端对其进行测试。
逻辑与网络上的常规数据传输相同,例如TCP window 大小。这篇 wiki 文章 (https://en.wikipedia.org/wiki/Bandwidth-delay_product) 可能有助于阐明需要保持多个数据包/操作在运行中的概念。对于 redis 请求,总延迟包括处理时间 + 网络时间。如果你在这方面遇到瓶颈,你将无法使服务器 CPU(或网络)保持 100% 繁忙。
请注意,实现 Instruction-Level Parallelism in a CPU 也是相同的概念。 (例如,要对一组浮点数求和,如果 FP add 具有 3 个周期延迟和每 1c 吞吐量一个,即完全流水线化,则您应该至少使用 3 个累加器)。