在Firefox 3中,答案是每个域6个:只要触发同一个域的第7个XmlHttpRequest(在任何选项卡上),它就会排队,直到其他6个完成为止。

其他主要浏览器的数字是多少?

此外,是否有办法绕过这些限制而不让用户修改浏览器设置?例如,jsonp请求(使用脚本标记注入而不是XmlHttpRequest对象)的数量是否有限制?

背景:我的用户可以从web页面到服务器进行xmlhttprequest,要求服务器在远程主机上运行ssh命令。如果远程主机宕机,ssh命令会在几分钟后失效,最终阻止用户执行任何进一步的命令。


当前回答

根据IE 9 -什么改变了?在HttpWatch博客上,IE9在VPN上仍然有2个连接限制。

使用VPN仍然会破坏IE 9的性能 我们之前报道过 关于上限的缩减 IE的并发连接数 8当你的PC使用VPN连接时。 这种情况即使发生在浏览器 交通没有经过那里 连接。 不幸的是,IE 9受到VPN的影响 以同样的方式连接:

其他回答

我写了一个单文件AJAX测试器。享受它! 只是因为我和我的主机供应商有问题

<?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>&nbsp;&nbsp;/2=<th>'+Math.ceil(what/2)+
       '<td>&nbsp;&nbsp;/3=<th>'+Math.ceil(what/3)+
       '<td>&nbsp;&nbsp;/4=<th>'+Math.ceil(what/4)+
       '<td>&nbsp;&nbsp;/6=<th>'+Math.ceil(what/6)+
       '<td>&nbsp;&nbsp;/8=<th>'+Math.ceil(what/8)+
       '<td> &nbsp; (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 + '>&nbsp;'
    $('#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>&nbsp;</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)

根据IE 9 -什么改变了?在HttpWatch博客上,IE9在VPN上仍然有2个连接限制。

使用VPN仍然会破坏IE 9的性能 我们之前报道过 关于上限的缩减 IE的并发连接数 8当你的PC使用VPN连接时。 这种情况即使发生在浏览器 交通没有经过那里 连接。 不幸的是,IE 9受到VPN的影响 以同样的方式连接:

Browserscope的网络结果将为您提供每个主机名的连接数和流行浏览器的最大连接数。数据是通过对“野外”用户运行测试来收集的,因此它将保持最新。

我刚刚检查了www.browserscope.org和IE9和Chrome 24,你可以有6个并发连接到一个域,最多17到多个域。

在IE6 / IE7中,用户可以调整注册表中的并发请求数量。下面是如何设置为四个。

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MaxConnectionsPerServer"=dword:00000004
"MaxConnectionsPer1_0Server"=dword:00000004