每个主机限制的 HTTP 同时连接数...是每个选项卡、浏览器实例还是全局? [英] HTTP simultaneous connections per host limit... are per tab, browser instance or global?

查看:14
本文介绍了每个主机限制的 HTTP 同时连接数...是每个选项卡、浏览器实例还是全局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 HTTP 规范 (w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4),HTTP 客户端应限制其连接:

<块引用>

使用持久连接的客户端应该限制它们与给定服务器保持的同时连接的数量.单用户客户端不应与任何服务器或代理保持 2 个以上的连接.

不同的供应商以不同的方式实施此限制:http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/

但是.此限制适用于每个选项卡、每个浏览器实例还是全局适用于浏览器的所有实例?弹出窗口(对话框)是标签的一部分还是独立标签的一部分?

对于 websockets 来说,每个源的连接限制是否适用于每个选项卡、浏览器实例或全局?

解决方案

浏览器

不同浏览器、浏览器版本或互联网连接速度的实现细节肯定会有所不同(IE8 使用 2 个拨号连接,否则最多 6 个).

此外,这些限制通常是用户可配置的(即 Mozilla 中的 network.http.max-connections-per-server),不应根据浏览器版本假定特定值.不过,实际值可能可以通过脚本访问,例如 IE 中的 window.maxConnectionsPerServer.

<块引用>

但是.此限制适用于每个选项卡、每个浏览器实例还是全局适用于浏览器的所有实例?

我发现的唯一相关信息是关于 IE (http://social.msdn.microsoft.com/Forums/ie/en-US/a46bb0ba-419d-43ec-ad1b-f9596d508ca3/simultaneous-http-连接限制):

<块引用>

连接限制是每个进程,浏览器将决定进程创建作为网站所有者,您无法真正更改它.该过程可能会在多个选项卡/窗口之间共享,也可能不会,这取决于您无法控制的许多因素

有关浏览器的更多最新数据可在 www.browserscope.org/?category=network

RFC

有一个更新的草案,它废弃了 RFC2616(如果获得批准).引用相关部分(来自 https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p1-messaging-21#section-6.2.3):

<块引用>

6.2.3.并发

<块引用>

客户端应该限制同时连接的数量维护到给定的服务器.

<块引用>

HTTP 的先前修订版给出了特定数量的连接作为天花板,但发现这对于许多应用程序来说是不切实际的.因此,本规范没有规定特定的最大值连接数,而是鼓励客户打开多个连接时保守.

<块引用>

通常使用多个连接来避免head-of-line"阻塞"问题,其中需要大量服务器的请求侧处理和/或具有大的有效载荷阻止后续请求在同一个连接上.但是,每个连接都消耗服务器资源.此外,使用多个连接会导致拥塞网络中的不良副作用.

<块引用>

请注意,服务器可能会拒绝他们认为滥用的流量,包括来自客户端的过多连接.

According to the HTTP Specification (w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4), HTTP clients should limit their connections:

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.

Different vendors implement this limit differently: http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/

But. does this limitation applies per tab, per browser instance or globally for all the instances of the browser? Are pop-ups (dialogs) considered part of a tab or independent tabs?

Same for websockets, does the limit on connections per origin applies per tab, browser instance or globally?

解决方案

Browsers

The implementation details are bound to be different for different browsers, browser versions or internet connection speeds (IE8 uses 2 connections on dial-up and up to 6 otherwise).

Also, these limits are usually user-configurable (i.e. network.http.max-connections-per-server in Mozilla) and one shouldn't assume specific values based on the browser version. The actual value might be accessible to a script though, such as window.maxConnectionsPerServer in IE.

But. does this limitation applies per tab, per browser instance or globally for all the instances of the browser?

The only relevant piece of information I found was this regarding IE (http://social.msdn.microsoft.com/Forums/ie/en-US/a46bb0ba-419d-43ec-ad1b-f9596d508ca3/simultaneous-http-connection-limit):

The connection limit is per process, the browser will make the determination about process creation as a web site owner you can't really change that. The process may be shared between multiple tabs/windows or it may not, it depends on many factors outside your control

More current data about browsers can be found at www.browserscope.org/?category=network

RFC

There is an updated draft which obsoletes RFC2616 (if approved). Citing the relevant part (from https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p1-messaging-21#section-6.2.3):

6.2.3. Concurrency

Clients SHOULD limit the number of simultaneous connections that they maintain to a given server.

Previous revisions of HTTP gave a specific number of connections as a ceiling, but this was found to be impractical for many applications. As a result, this specification does not mandate a particular maximum number of connections, but instead encourages clients to be conservative when opening multiple connections.

Multiple connections are typically used to avoid the "head-of-line blocking" problem, wherein a request that takes significant server- side processing and/or has a large payload blocks subsequent requests on the same connection. However, each connection consumes server resources. Furthermore, using multiple connections can cause undesirable side effects in congested networks.

Note that servers might reject traffic that they deem abusive, including an excessive number of connections from a client.

这篇关于每个主机限制的 HTTP 同时连接数...是每个选项卡、浏览器实例还是全局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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