views:

1551

answers:

6

Hi,

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 web app 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:

*.mysite.com/webapp  -> 123.456.789.1 (the actual ip of my server)

so:

a.mysite.com/webapp
b.mysite.com/webapp
c.mysite.com/webapp

all still point to (www.mysite.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.mysite.com/webapp
2) wwww.download.com/hugefile.zip
3) b.mysite.com/webapp
4) c.mysite.com/webapp
...
24) x.mysite.com/webapp
25) // Error - all 24 possible connections currently in use!

I just picked 24 connections/firefox as an example.

Thanks

A: 

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.

Blixt
+1  A: 
  1. Yes, wildcard domain will work for you.
  2. Not aware of any limits on connections. Limits if any will be browser specific.
Ryan Oberoi
+11  A: 

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

Firefox 2: 2
Firefox 3: 6
Opera 9.26: 4
Opera 9.5 beta: 4
Safari 3.0.4 Mac/Windows: 4
IE 7: 2
IE 8: 6

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

Alsciende
I'm surprised. Doesn't the HTTP 1.1 RFC say to limit persistent connections to 2 per server?
Adrian McCarthy
Yes it does. Recent browsers don't conform anymore.
Alsciende
@Adrian McCarthy: IE8 explicitly broke that standard, mainly because it wants to load pages more quickly. Firefox figured that out a bit earlier.
Dean J
+3  A: 

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.

Josh
I agree, it would probably be best to follow the standard.
palswim
+2  A: 

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.

Jethro Larson
Which version of Chrome? 6 or 5?
Husky
I think it was 6 but I'm on the dev channel and it was a little while ago. The silent updates mean I have to check all the time.
Jethro Larson
A: 

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

palswim