views:

141

answers:

2

i´ve read somewhere that you can just have 2 connections (eg. ajax requests) to the same server. is this correct?

so you can´t run 3 ajax requests simultaneously? what will happen to the 3rd one?

and if I´ve got one iframe, then i can just run 1 ajax request at the time?

what is the easiest way to get around this?

what keywords could i use to search for more information regarding this on google?

+1  A: 

You read it right, browsers limit simultaneous connection to the exact same domain to 2 for any type of requests (script src, image src, ajax etc.) originating from a given document, it can be changed in registry for IE and about:config in Firefox.

One way to get around this is to have additional CNAMEs to your host.

Murali
are there any good tutorials to set this up in php?
weng
Sorry, I know nothing about PHP
Murali
what lanugage are u using? curious:)
weng
IE 8 / FF3 both increased the default number of concurrent connections per host to 6
Sam
+3  A: 

The 2 connection maximum pr server is mandated in the HTTP RFC 2616 section 8.1 http://www.ietf.org/rfc/rfc2616.txt

Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion.

Q:what will happen to the 3rd one?

The third one will be queued untill one of the other HTTP calls return

Q:and if I´ve got one iframe, then i can just run 1 ajax request at the time?

The iFrame will be loaded through a HTTP connection, but once the HTML content has be returned the HTTP call has been completed and you again have 2 available HTTP connections

Q:what is the easiest way to get around this?

The most important is not to have long running HTTP requests, i.e. speed up processing on the server side. As long as HTTP requests are responded to in less than 100 ms, it is for normal apps not a problem.

dparnas
but im using comet and it will use long running requests, which is the purpose. hope the server will handle it..
weng
Also note wizard@'s response, which states the nice "optimization" that you can force more than two connections to your site if you create several additional CNAMES (e.g. foo1.bar.com, foo2.bar.com). Hower, this has some other drawbacks.
csl