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.
BrowserVersion | ConnectionsPerHostname | MaxConnections
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.
HTTP/1.1
source: http://p2p.wrox.com/book-professional-website-performance-optimizing-front-end-back-end-705/
HTTP/2(SPDY)
Max Number of default simultaneous persistent connections per server/proxy:
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).
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
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.