title: multiple ajax request to the same ASP.NET Action at the same time
body: <p>So I have this Action in my asp.net mvc controller which receives an int parameter and returns some json dependent on it. this is how that action looks</p>
  
  <pre><code>Public JsonResult GetSomeData(int intParam)
  {
      var someData = _someService.GetSomeDataByIntParam(intParam);
      return Json(someData);
  }
  </code></pre>
  
  <p>So there is nothing special in here, all the work needed is done by instance of <code>SomeService</code> and then the action just returns the json. this part <code>_someService.GetSomeDataByIntParam(intParam);</code> takes from 35-80 milliseconds on average.
  In front-end I have and Jquery code that makes Ajax call to this action and when it gets the answer it just puts the data from json somewhere in the DOM. this is the jquery code (including some <code>razor</code>)</p>
  
  <pre><code>@foreach (var intParam in Model.IntParams)
  {
      &lt;script type="text/javascript"&gt;
          $.ajax({
              type: 'POST',
              url: '/SomeController/GetSomeData',
              data { intParam: @intParam }, 
              success : function (response) {
                  var responseParam = response.param;
                  if (response.anotherParam)
                      responseParam += '&lt;span class="some-class"&gt;!&lt;/span&gt;';
  
                  var someForm1 = $('#some-from1-@intParam');
                  someForm1.children('span.some-another-class').html(responseParam);
  
                  var someForm2 = $('#some-from2-@intParam');
                  someForm2.children('span.some-another-class').html(responseParam);
              }
          });
      &lt;/script&gt;
  }
  </code></pre>
  
  <p>There will be on average 3-10 elements int <code>IntParams</code>. that js is executed immediately after the page is rendered. So whole scenario is like this. page is drawn the json data is queried and when its delivered back to js it is inserted somewhere in the DOM. the action which is returning json is queuing other request while it is executing one. so when those, suppose 5 ajax calls are made to the action only one gets executed at a time. (can this be made asynchronous without turning session state off ?) first request gets the answer in 30-80 milliseconds and the fifth gets the answer in 2-2.2 seconds. this is very crucial part in my application so I don't want to lose any milliseconds. I don't understand If the action takes on average 30-80 milliseconds why the fifth one gets the answer in 2 seconds. should not it be something like 400 (5 * 80) milliseconds ? or this call queuing is the thing that is taking too much time ? What can be done to make some optimizations. I image if there were more than 10 calls to execute it would take something like 5 seconds or so. So anyway what can be done to make this whole thing fast. Any suggestion would be appreciated. (even in js code)</p>