Max parallel http connections in a browser?

2018-12-30 23:48发布

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.

12条回答
只靠听说
2楼-- · 2018-12-31 00:32

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.

查看更多
弹指情弦暗扣
3楼-- · 2018-12-31 00:37

Doing testing on a page I saw this behavior:

Safari 4: 6  
Chrome 6: 7  
FF 4: 6

Edit: Seems that firefox 4 should be able to do 15 connections but that's not the behavior I observed.

查看更多
妖精总统
4楼-- · 2018-12-31 00:38

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)

查看更多
低头抚发
5楼-- · 2018-12-31 00:39

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.

查看更多
十年一品温如言
6楼-- · 2018-12-31 00:43

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.

查看更多
只靠听说
7楼-- · 2018-12-31 00:47

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/

查看更多
登录 后发表回答