浏览器中的最大并行 HTTP 连接数?

发布于 2024-07-24 08:37:51 字数 833 浏览 12 评论 0原文

我正在创建一些与 HTTP 服务器的挂起连接(comet、反向 AJAX 等)。 它工作正常,但我看到浏览器只允许同时与给定域有两个挂起的连接。 因此,如果用户在浏览器的 Tab1 中查看我的网站,然后又尝试在 Tab2 中加载它,他们就会用完与我的网站的两个允许的连接。

我想我可以做一些通配符域的事情,我让我的HTTP服务器解析我网站的任何地址,例如:

*.example.com/webapp  -> 192.0.2.1 (the actual ip of my server)

所以:

a.example.com/webapp
b.example.com/webapp
c.example.com/webapp

所有仍然指向(www.example.com/webapp),但浏览器认为它们是不同的域,所以我不会遇到 2 个连接的限制。 这是真的?

即使这是真的 - 所有域中每个浏览器的活动连接数是否有限制? 假设我使用上面的方案 - 例如 Firefox 在任何给定时间只允许 24 个并行连接吗? 比如:

1) a.example.com/webapp
2) www.download.example/hugefile.zip
3) b.example.com/webapp
4) c.example.com/webapp
...
24) x.example.com/webapp
25) // Error - all 24 possible connections currently in use!

我刚刚选择了 24 个连接/Firefox 作为示例。

I am creating some suspended connections to an HTTP server (comet, reverse AJAX, etc). It works ok, but I see the browser only allows two suspended connections to a given domain simultaneously. So if a user is looking at my website in Tab1 of their browser, then also tries loading it in Tab2, they've used up the two allowed connections to my site.

I think I can do some wildcard domain thing, where I have my HTTP server resolve any address to my site like:

*.example.com/webapp  -> 192.0.2.1 (the actual ip of my server)

so:

a.example.com/webapp
b.example.com/webapp
c.example.com/webapp

all still point to (www.example.com/webapp) but the browser considers them different domains, so I don't run into the 2 connection limit. Is this true?

Even if that is true - is there any limit to the number of active connections per browser, across all domains? Say I use the scheme above - does Firefox for example only allow 24 parallel connections at any given time? Something like:

1) a.example.com/webapp
2) www.download.example/hugefile.zip
3) b.example.com/webapp
4) c.example.com/webapp
...
24) x.example.com/webapp
25) // Error - all 24 possible connections currently in use!

I just picked 24 connections/Firefox as an example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

夜灵血窟げ 2024-07-31 08:37:51

每个服务器/代理的默认同时持久连接的最大数量:

Firefox 2:  2
Firefox 3+: 6
Opera 9.26: 4
Opera 12:   6
Safari 3:   4
Safari 5:   6
IE 7:       2
IE 8:       6
IE 10:      8
Edge:       6
Chrome:     6

限制是每个服务器/代理,因此您的通配符方案将起作用。

仅供参考:这与 HTTP 1.1 特别相关; 其他协议有单独的关注点和限制(即 SPDY、TLS、HTTP 2)。

Max Number of default simultaneous persistent connections per server/proxy:

Firefox 2:  2
Firefox 3+: 6
Opera 9.26: 4
Opera 12:   6
Safari 3:   4
Safari 5:   6
IE 7:       2
IE 8:       6
IE 10:      8
Edge:       6
Chrome:     6

The limit is per-server/proxy, so your wildcard scheme will work.

FYI: this is specifically related to HTTP 1.1; other protocols have separate concerns and limitations (i.e., SPDY, TLS, HTTP 2).

眼角的笑意。 2024-07-31 08:37:51

HTTP/1.1

IE 6 and 7:      2
IE 8:            6
IE 9:            6
IE 10:           8
IE 11:           8
Firefox 2:       2
Firefox 3:       6
Firefox 4 to 46: 6
Opera 9.63:      4
Opera 10:        8
Opera 11 and 12: 6
Chrome 1 and 2:  6
Chrome 3:        4
Chrome 4 to 23:  6
Safari 3 and 4:  4

来源:http:// /p2p.wrox.com/book-professional-website-performance-optimizing-front-end-back-end-705/

HTTP/2(SPDY)

Multiplexed support(one single TCP connection for all requests)

HTTP/1.1

IE 6 and 7:      2
IE 8:            6
IE 9:            6
IE 10:           8
IE 11:           8
Firefox 2:       2
Firefox 3:       6
Firefox 4 to 46: 6
Opera 9.63:      4
Opera 10:        8
Opera 11 and 12: 6
Chrome 1 and 2:  6
Chrome 3:        4
Chrome 4 to 23:  6
Safari 3 and 4:  4

source: http://p2p.wrox.com/book-professional-website-performance-optimizing-front-end-back-end-705/

HTTP/2(SPDY)

Multiplexed support(one single TCP connection for all requests)
混浊又暗下来 2024-07-31 08:37:51

2015 年情况

 BrowserVersion | ConnectionsPerHostname | MaxConnections
----------------------------------------------------------
 Chrome34/32    | 6                      | 10
 IE9            | 6                      | 35
 IE10           | 8                      | 17
 IE11           | 13                     | 17
 Firefox27/26   | 6                      | 17
 Safari7.0.1    | 6                      | 17
 Android4       | 6                      | 17
 ChromeMobile18 | 6                      | 16
 IE Mobile9     | 6                      | 60

第一个值是 ConnectionsPerHostname,第二个值是 MaxConnections

来源是现已解散的 Browserscope 项目。 仍然可以通过 Wayback Machine 查看特定页面

注意:ConnectionsPerHostname 是浏览器向同一域发出的并发 HTTP 请求的最大数量。
为了增加并发连接的数量,可以将资源(例如图像)托管在不同的域中。 但是,您不能超过
MaxConnections,浏览器在所有域中总共打开的最大连接数。

2020 更新

每个浏览器的并行连接数

| Browser              | Connections per Domain         | Max Connections                |
| -------------------- | ------------------------------ | ------------------------------ |
| Chrome 81            | 6 [^note1]                     | 256[^note2]                    |
| Edge 18              | *same as Internet Explorer 11* | *same as Internet Explorer 11* |
| Firefox 68           | 9 [^note1] or 6 [^note3]       | 1000+[^note2]                  |
| Internet Explorer 11 | 12 [^note4]                    | 1000+[^note2]                  |
| Safari 13            | 6 [^note1]                     | 1000+[^note2]                  |
  • [^note1]:使用 72 个请求进行测试,1 个域 (127.0.0.1)
  • [^note2]:使用 1002 个请求进行测试,每个域 6 个请求 * 167 个域 (127.0.0.*)
  • [ ^note3]:当在异步上下文中调用时,例如在 setTimeout 的回调中,+ requestAnimationFramethen...
  • [^note4]:其中后 6 个为后续(2、4、6 分别为 0.5s、1s、1.5s)

2015 Situation

 BrowserVersion | ConnectionsPerHostname | MaxConnections
----------------------------------------------------------
 Chrome34/32    | 6                      | 10
 IE9            | 6                      | 35
 IE10           | 8                      | 17
 IE11           | 13                     | 17
 Firefox27/26   | 6                      | 17
 Safari7.0.1    | 6                      | 17
 Android4       | 6                      | 17
 ChromeMobile18 | 6                      | 16
 IE Mobile9     | 6                      | 60

The first value is ConnectionsPerHostname and the second value is MaxConnections.

The source is the now defunct Browserscope project. The specific page can still be seen via the Wayback Machine.

Note: ConnectionsPerHostname is the maximum number of concurrent HTTP requests that browsers will make to the same domain.
To increase the number of concurrent connections, one can host resources (e.g. images) in different domains. However, you cannot exceed
MaxConnections, the maximum number of connections a browser will open in total - across all domains.

2020 Update

Number of parallel connections per browser

| Browser              | Connections per Domain         | Max Connections                |
| -------------------- | ------------------------------ | ------------------------------ |
| Chrome 81            | 6 [^note1]                     | 256[^note2]                    |
| Edge 18              | *same as Internet Explorer 11* | *same as Internet Explorer 11* |
| Firefox 68           | 9 [^note1] or 6 [^note3]       | 1000+[^note2]                  |
| Internet Explorer 11 | 12 [^note4]                    | 1000+[^note2]                  |
| Safari 13            | 6 [^note1]                     | 1000+[^note2]                  |
  • [^note1]: tested with 72 requests , 1 domain(127.0.0.1)
  • [^note2]: tested with 1002 requests, 6 requests per domain * 167 domains (127.0.0.*)
  • [^note3]: when called in async context, e.g. in callback of setTimeout, + requestAnimationFrame, then...
  • [^note4]: of which the last 6 are follow-ups (2,4,6 available at 0.5s,1s,1.5s respectively)
关于从前 2024-07-31 08:37:51

各种浏览器对每个主机名的最大连接数有不同的限制; 您可以在 http://www.browserscope.org/?category=network
这里有一篇关于网络性能专家 Steve Souders 的关于连接限制的有趣文章 http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/

Various browsers have various limits for maximum connections per host name; you can find the exact numbers at http://www.browserscope.org/?category=network
and here is an interesting article about connection limitations from web performance expert Steve Souders http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/

讽刺将军 2024-07-31 08:37:51

Firefox 在此设置中存储该数字(您可以在 about:config 中找到它): network.http.max-connections-per-server

对于最大连接数,Firefox 会存储该数字在此设置中:network.http.max-connections

Firefox stores that number in this setting (you find it in about:config): network.http.max-connections-per-server

For the max connections, Firefox stores that in this setting: network.http.max-connections

各自安好 2024-07-31 08:37:51

在 GNU/Linux (Ubuntu) 上的 Firefox 33 上查看 about:config 并搜索 connections 我发现:

网络.http.最大连接数:256

这可能会回答以下部分:跨所有域的每个浏览器的活动连接数是否有限制

network.http.每个代理的最大持久连接数:32

network.http.每服务器最大持久连接数:6

跳过了两个属性...

network.websocket.max-connections: 200

(有趣的是,它们似乎不受每个服务器的限制,但默认值低于全局http连接)

Looking at about:config on Firefox 33 on GNU/Linux (Ubuntu), and searching connections I found:

network.http.max-connections: 256

That is likely to answer the part is there any limit to the number of active connections per browser, across all domain

network.http.max-persistent-connections-per-proxy: 32

network.http.max-persistent-connections-per-server: 6

skipped two properties...

network.websocket.max-connections: 200

(interesting, seems like they are not limited per server but have a default value lower than global http connections)

鼻尖触碰 2024-07-31 08:37:51

2 个并发请求是许多浏览器设计的有意部分。 有一个“好的 http 客户端”有意遵守的标准。 查看此 RFC 了解原因。

The 2 concurrent requests is an intentional part of the design of many browsers. There is a standard out there that "good http clients" adhere to on purpose. Check out this RFC to see why.

迷爱 2024-07-31 08:37:51

请注意,将每台服务器的浏览器最大连接数增加到过多(正如某些站点所建议的那样)可以并且确实会将其他用户锁定在小型站点之外,而这些站点的托管计划会限制服务器上的总并发连接数。

Note that increasing a browser's max connections per server to an excessive number (as some sites suggest) can and does lock other users out of small sites with hosting plans that limit the total simultaneous connections on the server.

眼泪也成诗 2024-07-31 08:37:51
  1. 是的,通配符域名适合您。
  2. 不知道连接有任何限制。 限制(如果有)将特定于浏览器。
  1. Yes, wildcard domain will work for you.
  2. Not aware of any limits on connections. Limits if any will be browser specific.
寂寞清仓 2024-07-31 08:37:51

对此没有明确的答案,因为每个浏览器都有自己的配置,并且此配置可能会更改。 如果您在互联网上搜索,您可以找到更改此限制的方法(通常它们被标记为“性能增强方法”。)如果您的网站需要,建议您的用户这样做可能是值得的。

There is no definitive answer to this, as each browser has its own configuration for this, and this configuration may be changed. If you search on the internet you can find ways to change this limit (usually they're branded as "performance enhancement methods.") It might be worth advising your users to do so if it is required by your website.

粉红×色少女 2024-07-31 08:37:51

我的理解是连接限制在客户端是不可更改的。 必须在服务器上更改连接限制才能生效。 默认情况下,许多服务器只允许每个唯一客户端有 2 个连接。

客户端不是浏览器,而是发出 TCP/IP 请求的客户端计算机。

要非常清楚地看到效果,请使用 JMeter 之类的工具向您的服务器主机发起一系列 Web 服务调用 - 它将接受前两个调用,并且在两个调用之一完成之前不会接受另一个调用。 令人惊奇的是,对于 SOA 商店来说,这是至关重要的,但几乎没有人真正意识到这一点。

My understanding is that the connection limit is not changeable on the client side. The connection limit must be changed on the server to have any effect. By default, many servers will only allow 2 connections per unique client.

The client is not the browser, it is the client machine issuing the TCP/IP requests.

To see the effect very clearly, use something like JMeter to fire off a bunch of web service calls to your server host - it will accept the first two and will not accept another until one of the two is completed. The amazing thing about this is that for a SOA shop, this is critical, yet hardly anyone is really aware of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文