How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers?
Solution 1
One trick you can use to increase the number of concurrent connections is to host your images from a different sub domain. These will be treated as separate requests, each domain is what will be limited to the concurrent maximum.
IE6, IE7 - have a limit of two. IE8 is 6 if you have a broadband - 2 (if it's a dial up).
Solution 2
The network results at Browserscope will give you both Connections per Hostname and Max Connections for popular browsers. The data is gathered by running tests on users "in the wild," so it will stay up to date.
Solution 3
With IE6 / IE7 one can tweak the number of concurrent requests in the registry. Here's how to set it to four each.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MaxConnectionsPerServer"=dword:00000004
"MaxConnectionsPer1_0Server"=dword:00000004
Solution 4
I just checked with www.browserscope.org and with IE9 and Chrome 24 you can have 6 concurrent connections to a single domain, and up to 17 to multiple ones.
Solution 5
I have writen a single file AJAX tester. Enjoy it!!! Just because I have had problems with my hosting provider
<?php /*
Author: Luis Siquot
Purpose: Check ajax performance and errors
License: GPL
site5: Please don't drop json requests (nor delay)!!!!
*/
$r = (int)$_GET['r'];
$w = (int)$_GET['w'];
if($r) {
sleep($w);
echo json_encode($_GET);
die ();
} //else
?><head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var _settimer;
var _timer;
var _waiting;
$(function(){
clearTable();
$('#boton').bind('click', donow);
})
function donow(){
var w;
var estim = 0;
_waiting = $('#total')[0].value * 1;
clearTable();
for(var r=1;r<=_waiting;r++){
w = Math.floor(Math.random()*6)+2;
estim += w;
dodebug({r:r, w:w});
$.ajax({url: '<?php echo $_SERVER['SCRIPT_NAME']; ?>',
data: {r:r, w:w},
dataType: 'json', // 'html',
type: 'GET',
success: function(CBdata, status) {
CBdebug(CBdata);
}
});
}
doStat(estim);
timer(estim+10);
}
function doStat(what){
$('#stat').replaceWith(
'<table border="0" id="stat"><tr><td>Request Time Sum=<th>'+what+
'<td> /2=<th>'+Math.ceil(what/2)+
'<td> /3=<th>'+Math.ceil(what/3)+
'<td> /4=<th>'+Math.ceil(what/4)+
'<td> /6=<th>'+Math.ceil(what/6)+
'<td> /8=<th>'+Math.ceil(what/8)+
'<td> (seconds)</table>'
);
}
function timer(what){
if(what) {_timer = 0; _settimer = what;}
if(_waiting==0) {
$('#showTimer')[0].innerHTML = 'completed in <b>' + _timer + ' seconds</b> (aprox)';
return ;
}
if(_timer<_settimer){
$('#showTimer')[0].innerHTML = _timer;
setTimeout("timer()",1000);
_timer++;
return;
}
$('#showTimer')[0].innerHTML = '<b>don\'t wait any more!!!</b>';
}
function CBdebug(what){
_waiting--;
$('#req'+what.r)[0].innerHTML = 'x';
}
function dodebug(what){
var tt = '<tr><td>' + what.r + '<td>' + what.w + '<td id=req' + what.r + '> '
$('#debug').append(tt);
}
function clearTable(){
$('#debug').replaceWith('<table border="1" id="debug"><tr><td>Request #<td>Wait Time<td>Done</table>');
}
</script>
</head>
<body>
<center>
<input type="button" value="start" id="boton">
<input type="text" value="80" id="total" size="2"> concurrent json requests
<table id="stat"><tr><td> </table>
Elapsed Time: <span id="showTimer"></span>
<table id="debug"></table>
</center>
</body>
Edit:
r means row and w waiting time.
When you initially press start button 80 (or any other number) of concurrent ajax request are launched by javascript, but as is known they are spooled by the browser. Also they are requested to the server in parallel (limited to certain number, this is the fact of this question). Here the requests are solved server side with a random delay (established by w). At start time all the time needed to solve all ajax calls is calculated. When test is finished, you can see if it took half, took third, took a quarter, etc of the total time, deducting which was the parallelism on the calls to the server. This is not strict, nor precise, but is nice to see in real time how ajaxs calls are completed (seeing the incoming cross). And is a very simple self contained script to show ajax basics.
Of course, this assumes, that server side is not introducing any extra limit.
Preferably use in conjunction with firebug net panel (or your browser's equivalent)
Michael Gundlach
Updated on July 08, 2022Comments
-
Michael Gundlach almost 2 years
In Firefox 3, the answer is 6 per domain: as soon as a 7th XmlHttpRequest (on any tab) to the same domain is fired, it is queued until one of the other 6 finish.
What are the numbers for the other major browsers?
Also, are there ways around these limits without having my users modify their browser settings? For example, are there limits to the number of jsonp requests (which use script tag injection rather than an XmlHttpRequest object)?
Background: My users can make XmlHttpRequests from a web page to the server, asking the server to run ssh commands on remote hosts. If the remote hosts are down, the ssh command takes a few minutes to fail, eventually preventing my users from performing any further commands.
-
Michael Gundlach over 15 yearsThanks, Bob. So are you saying that FF actually limits all requests to 6, not just AJAX requests?
-
Bob over 15 yearsNo, the limits are imposed on the domain. So you could technically get FF up to 12 connections if you had a subdomain in addition to your site.
-
Bob over 15 yearsJust to clarify, the browser does the limiting (server can technically have its own) based on the name of the domain.
-
Michael Gundlach over 15 yearsMy XmlHttpRequests cannot go to different domains as you suggest, due to the Same Origin Policy. (Perhaps this is an argument for using jsonp to get around this problem.) This page is a command-and-control dashboard for many computers; thus a request is spawned per execution requested by the user.
-
Michael Gundlach over 15 yearsSo if I understand you, FF limits all requests (to a single domain) to 6 -- not just XmlHttpRequests to a single domain. And other browsers do the same thing with different limits. Correct?
-
Bob over 15 yearsOhh yes, If you have a page with a thousand images, it will download them in groups of six. I believe most other mainstream browsers work the same way.
-
Luis Siquot about 13 yearsso I confirm, FF3 launches up to six concurrent requests
-
Razort4x about 11 years-1. OP said
without having my users modify their browser settings
. Also, it not practical since one would have to do this on each client. -
JD Smith about 11 yearsThis is nonetheless a very useful thing to know, related to this issue. Perhaps it would have been better posted in a comment than as an answer?
-
meawoppl about 11 yearsWow. This is a good trick. This also explains why tile-servers for map engines create a number of fake sub-domains (typically something like maps1.whatever.com, maps2.whatever.com, maps3.whatever.com) to accelerate things.
-
AMember over 10 yearswill the browser wait for the whole group to finish loading before it will continue to the next group fetch or will it keep the stack of concurrent requests full and replace a finished task with another?
-
Royi Namir about 10 yearsCan u please explain what you did here ? What is r and w ? Print screen of analyzing result would be much appreciated
-
Luis Siquot about 10 years@AMember, the browser keeps in parallel its maximum number of concurrent ajax allowed all the time. Try my answer below if you want to see in action
-
Tom about 8 yearsWould be nice if this got updated with more recent browsers.
-
Dave Lawrence over 7 yearsUnfortunately that does not look remotely up to date
-
PauAI over 7 yearsIt says 19 on mine, is it broken?
-
Simon East almost 7 years@DaveLawrence I just checked and the full data set seems to contain Chrome 60 and 61 which is pretty up to date.
-
AnthonyB over 6 yearsFirefox Developer Edition 57.0b12 says 2.
-
felickz over 3 yearsAnyone have alterntives to browserscope to test this, looks like tooling is no longer hosted.
-
RamPrakash over 2 yearsWhat abt ajax requests on HTTP2? browsers have no support for that as of now.
-
Raskolnikov over 2 years@RamPrakash thats not ture. You can see an h2 protocol on the network tab of Chrome... That show http2 connection
-
RamPrakash over 2 yearsThat is for static files. not for ajax requests. Can you show me a link where you see? It is a limitation as of now with browsers.