views:

177

answers:

2

Is there a limit to the number of simultaneous Ajax requests than can be launched toward an Apache server? For example, consider the following function to update div elements on a page (prototype JS):

function trigger_content_update(cell) {
 //asynchronous : false is required for this to work properly
 $$('.update').each(function(update_item){  
  new Ajax.Request('/neighbouring?.state=update_template&dummy='+(new Date()).getTime(),{
   asynchronous: false,
   parameters: {divid: update_item.id, source: cell},
   onComplete: function(response) {
    var elm = response.getHeader('Element');
    if ($(elm) !== null) { $(elm).update(response.responseText) }
   }
  });
});

}

On my HTML page, there are 8 div elements that are marked with the "update" CSS selector, thus launching 8 ajax requests. The code works fine with the asynchronous property set to false, but as soon as i set asynchronous:true i can observe (in Firebug) most Ajax requests returning a 500 status (internal server error).

Once this occurs, it is required to restart apache to recover.

+1  A: 

I'd check the server side code that's handling the requests.

As far as Apache is concerned, your Ajax request is just a POST - the same as if you'd submitted a form. 8 simultaneous requests should easily be handled by Apache, so it suggests that the server side code that Apache is running is locking up - perhaps it's trying to write to a data file and finding it locked?

Hippyjim
Thanks, i'll inspect my server side code with a magnifying glass and report back.
Hartmut Behrens
+1  A: 

I just wrote a test case where I sent out 10,000 simultanuous Ajax calls to a service. Works fine on Apache Tomcat. All service came back with a proper answer.

It sounds like your service is having some internal synchronization issues.

Chris Laffra