【发布时间】:2011-09-13 04:57:29
【问题描述】:
Clients that use persistent connections SHOULD limit the number of simultaneous
connections that they maintain to a given server. A single-user client SHOULD
NOT maintain more than 2 connections with any server or proxy.
[..]
我特别不确定“应该”..它是什么意思?为什么?
我知道 HTTP 持久连接,也称为 HTTP keep-alive,是使用同一个 TCP 连接来发送和接收多个 HTTP 请求/响应的想法,而不是为每个请求/响应对打开一个新连接.我知道使用持久连接对于提高 HTTP 性能非常重要。
- 是否预定义了每个服务器的 2 个连接限制?
- 请求何时使用现有连接或获取新连接?
假设我有一个包含以下图片引用的 HTML 页面:
<img src="http://example.com/image1.gif"/>
<img src="http://example.com/image2.gif"/>
<img src="http://example.com/image3.gif"/>
<img src="http://example.com/image4.gif"/>
我的服务器的 keep-alive 指令已打开:就持久连接而言,这里发生了什么??与以下 2 个同时连接每服务器限制相关的优化规则/技巧是否有效?
<img src="http://example.com/image1.gif"/>
<img src="http://example.com/image2.gif"/>
<img src="http://example2.com/image3.gif"/>
<img src="http://example2.com/image4.gif"/>
谢谢
【问题讨论】:
-
除此之外,这是一个问题,遵循RFC的客户需要担心。对于服务器端的人来说这不是问题...... :)
-
DNS 别名的诀窍不是针对具有 4 个图像的简单页面,它更多地用于 GIS 应用程序(如 gmap 或 openlayers),当需要并行上传大量图像时。对于您的服务器 KeepAlive 设置,您应该只担心会有一个小的 keepAlive 超时(2 或 3 秒而不是 15 秒),以防止您的网络服务器将所有孩子的时间都花在无所事事上。
标签: http connection keep-alive