从Web服务器端保持活力的利弊 [英] Pros and Cons of Keep-Alive from Web Server Side

查看:94
本文介绍了从Web服务器端保持活力的利弊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP协议中的Keep-Alive连接功能旨在减少到Web服务器的TCP连接命中。它应该能够提高Web服务器性能。但是,我发现一些Web服务器故意从服务器端禁用KeepAlive功能。

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.

根据我的理解,一些反向代理,即HAProxy,禁用HTTP keep-alive以减少内存使用,这在某些情况下比CPU使用更为关键。

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.

Web服务器禁用Keep-Alive还有其他原因吗?

Is there any other reason why Web server disables Keep-Alive?

推荐答案

实际上,Keep-Alive意味着提高HTTP性能,而不是服务器性能(尽管对于SSL连接,它确实降低了服务器上重新协商加密的成本)。最大的胜利在于浏览器为获取内容而必须进行的往返次数。使用Keep-Alives,浏览器可以在第一次请求后消除每次请求的完整往返,通常会将整页加载时间缩短一半。

Actually, Keep-Alive is mean 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-Alives the browser gets to eliminate a full round trip for every request after the first, usually cutting full page load times in half.

Keep-Alives实际上增加了服务器加载这是一些共享主机提供商禁用它的原因。每个开放连接都消耗内存和文件描述符(linux),在极端情况下(某些Apache配置),它可能具有从连接到进程的1:1映射。

Keep-Alives actually 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.

这篇关于从Web服务器端保持活力的利弊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆