Atlas 4: Only 2 calls at a time and don’t expect any order

Browsers make 2 concurrent AJAX calls at a time to a domain. If
you make 5 AJAX calls, browser is going to make 2 calls first, then
wait for any one of them to complete and then make another call
until all remaining 4 calls are complete. Moreover, you cannot
expect calls to execute in the same order as you make the calls.
Here’s why:

Here you see, call 3’s response download is quite big and thus
takes longer than Call 5. So, Call 5 actually gets executed before
Call 3.

So, the world of HTTP is unpredictable.

6 thoughts on “Atlas 4: Only 2 calls at a time and don’t expect any order”

  1. Look at my blog where I’m writing about mistakes in AJAX applications. You should never run more than one request at the same time. Not only AJAX requests are queued because of the 2 concurrent http connections restriction, think on mouseover images!

    Michael

  2. Is there anyway to increase the concurrent http connections limit? What are the down side of it if we increase it? Anyways, it’s bad idea to call more than 2 requests at a time but when you deal with long running webservices (which takes more than 2-3 seconds), I wonder what else can be done!

  3. The behavior comes from a limitation within WinInet and as far as I know there is no fix, except using another component 😉

  4. As far as I know, a 2 connection limit is suggested in the HTTP/1.1 specification.

    I think it can be raised by the user through a registry setting, but there is a reason for setting it to 2: it is a balance between network load and webserver load combined with the fact that using 1 connection would show the stalls all the time, while with 2 there is at least a way to bypass a large request.

    Marijn

    BTW: Opera has the connection limit set higher ( 4 or 8, I do not remember), Firefox also defaults to 2 (for HTTP/1.1, I think it is 4 for HTTP/1.0)

    BTW2: Using HTTP pipelining, at least the start can coincide with a previous download

  5. You should be able to make more than two calls on a web page at a time by using subdomains (e.g. calling images.pageflakes.com), be careful about security errors with any Javascript though. Caleb Jenkins from Microsoft can/will confirm this.

Leave a Reply