I am writing a rather large JavaScript based application and sometimes there are cases when it has even eight (8) AJAX requests going on at once. This is a problem in IE6, because it kills the rest of the requests, I know that, but this application is targeted for modern browsers, so, IE6 is not a problem.
However, I have a feeling (have not done any actual profiling) that pooling requests could yield in better performance. Say, maximum of 4 requests at a time.
So, my question is that is there any benefit to pool AJAX requests or is it okay to have multiple requests going on at the same time compared to having a pool where they are processed one after another?
I realize that this might depend on the browser and Internet connection, but I am not sure about that.
The AJAX Toolkit uses SOAP API calls. SOAP calls always have a maximum limit of 50MB. However, it is also XML-based, which restricts the available characters you can use, so the file has to be Base-64 encoded. This puts the final limit at around 37 MB of binary data, as you've observed.
It is worth noting that browsers can generally only handle 6 ajax requests at a time, this may catch you out.
Where Should Ajax be Used? Ajax should be used anywhere in a web application where small amounts of information could be saved or retrieved from the server without posting back the entire pages. A good example of this is data validation on save actions.
IE6 isn't going to be your only problem; other browsers also limit the number of concurrent requests to the same server. Here's a good roundup, which says that as of that writing the defaults were:
Browser HTTP/1.1 HTTP/1.0 ------- -------- -------- IE 6,7 2 4 IE 8 6 6 Firefox 2 2 8 Firefox 3 6 6 Safari 3,4 4 4 Chrome 1,2 6 ? Chrome 3 4 4 Opera 9.63 4 4 Opera 10.00alpha 4 4
Aside from that, two other important quotes from that article:
It’s possible to reconfigure your browser to use different limits.
and
Note that IE8 automatically drops back to 2 connections per server for users on dialup connections.
...and for all you know, other modern browsers do, or may start doing so with their next "dot" release.
If you can, definitely try to keep the number of long-standing open connections to a minimum. Certainly don't actively keep more than one connection open for a long time.
If you're just doing a lot of individual, quick connections and sometimes they bunch up, you probably want to serialize them yourself rather than relying on the browser to do it. Have a queue of objects representing the request that needs to be done, and code responsible for doing them (one at a time).
too many
is always bad.
Read more about AJAX optimization in this article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With