Web 服务器端 Keep-Alive 的优点和缺点
HTTP 协议中的 Keep-Alive 连接功能旨在减少对 Web 服务器的 TCP 连接命中。它应该能够提高 Web 服务器的性能。但是,我发现一些 Web 服务器故意从服务器端禁用 KeepAlive 功能。
据我了解,某些反向代理(即 HAProxy)会禁用 HTTP keep-alive 以减少内存使用量,这在某些情况下比 CPU 使用量更重要。
Web 服务器禁用 Keep-Alive 是否还有其他原因?
Keep-Alive connection feature in HTTP protocol is meant to reduce TCP connection hits to web server. It should be able to improve web server performance. However, I found that some web servers deliberately disable KeepAlive feature from server side.
In my understanding, some reverse proxy, i.e. HAProxy, disables HTTP keep-alive in order to reduce memory usage which is more critical than CPU usage in some situation.
Is there any other reason why Web server disables Keep-Alive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,Keep-Alive 旨在提高 HTTP 性能,而不是服务器性能(尽管对于 SSL 连接,它确实降低了服务器重新协商加密的成本)。最大的胜利在于浏览器获取内容所需的往返次数。通过
Keep-Alive
,浏览器可以消除第一个请求之后每个请求的完整往返,通常将整个页面加载时间减少一半。Keep-Alive
会增加服务器负载,这就是一些共享托管提供商禁用它的原因。每个打开的连接都会消耗内存和文件描述符 (linux),在极端情况下(某些 Apache 配置),它可能具有从连接到进程的 1:1 映射。Actually, Keep-Alive is meant to improve HTTP performance, not server performance (though for SSL connections it does reduce the cost on the server of re-negotiating the encryption). The big win is in the number of round trips the browser has to make to get the content. With
Keep-Alive
the browser gets to eliminate a full round trip for every request after the first, usually cutting full page load times in half.Keep-Alive
increase server load which is why some shared hosting providers disable it. Each open connection consumes memory as well as a file descriptor (linux) and in extreme cases (some Apache configs) it may have a 1:1 mapping from connections to processes.