NoSQL / Redis 扩展理论
对于 Redis 之类的键值数据存储来说,通过 1 个客户端连接处理 X 个请求,或者通过 X 个客户端连接处理每个客户端 1 个请求,哪个效率更高?
Is it more efficient for a key-value data store such as Redis to handle X number of requests over 1 client connection or 1 request per client over X number of client connections?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
理论上,重用连接意味着连接开销所需的工作更少,因此技术上更加高效。然而,实际上,延迟意味着使用单个连接会显着变慢,因为服务器大部分时间都处于空闲状态。
Redis 的性能几乎永远不会受到 CPU 的限制 - 它可以很容易地在单独的连接上处理 100 个请求,否则它会花费在单个连接上等待第二个请求的时间。
In theory reusing a connection means that less work is required on the connection overhead so it is technically more efficient. However, in practice latency means that using a single connection is dramatically slower with the server being idle most of the time.
Redis performance is almost never limited by the CPU - it can quite easily serve 100 requests on separate connections in the time it would otherwise spend waiting for the second request on a single connection.