IIS HTTP 保持活动状态
我读到 Keep-Alives 是为了性能 - 因此不需要重新创建连接,而只需重用现有的连接。如果出现流量高峰怎么办,会创建新连接吗?
此外,如果我不打开 Keep-Alive 并且在高流量环境中,它最终会耗尽客户端的连接/套接字端口吗?因为必须为每个 http/web 请求创建一个新连接。
I am reading that Keep-Alives is meant for performance - so that no connections need to be recreated but just reuse the existing ones. What if there is a traffic spike, will new connections be created?
Additionally, if I don't turn on Keep-Alive and in a high traffic environment, will it eventually running out of connections/socket port on client side? because a new connection has to be created for each http/web request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP 是无状态协议。
在 HTTP 1.0 中,每个请求都意味着打开一个新的 TCP 连接。
这导致了性能问题(例如,必须为每个 GET 或 POST 重新进行 3 次握手),因此添加了
Keep-Alive
标头来维护跨请求的连接,并且在 HTTP1.1 中是默认的是持久连接。这意味着连接可以跨请求重用。
我对 IIS 不太熟悉,但如果有一个配置在每次 HTTP 响应后关闭连接,则会对性能产生影响。
关于客户端套接字/端口耗尽的问题,如果客户端发出大量请求并且每个 HTTP 请求必须打开一个新的 TCP 连接,则可能会发生这种情况。
一段时间后,端口将耗尽
HTTP is a stateless protocol.
In HTTP 1.0 each request meant opening a new TCP connection.
That caused performance issues (e.g. have to re-do the 3-way handshake for each GET or POST) so the
Keep-Alive
Header was added to maintain the connection across requests and in HTTP1.1 the default is persistent connection.This means that the connection is reused across requests.
I am not really familiar with IIS but if there is a configuration to close the connection after each HTTP response, it will have impact on the performance.
Concerning the running out of sockets/ports on the client side, that could occur if the client fires a huge amount of requests and a new TCP connection must be opened per HTTP request.
After a while the ports will be depleted