问题
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.
回答1:
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
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).
回答2:
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)
回答3:
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.
Source: http://www.browserscope.org/?category=network&v=top
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.
回答4:
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/
回答5:
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
回答6:
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.
回答7:
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.
回答8:
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)
回答9:
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.
回答10:
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.
回答11:
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.
回答12:
- Yes, wildcard domain will work for you.
- Not aware of any limits on connections. Limits if any will be browser specific.
来源:https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser