Reputation: 918
I have a page which executes four asynchronous ajax calls to four webservices (on an IIS server) one after the other in following way:
executeAjax('/get_parent_List.asmx',blah, blah, blah, successCallBack,errorCallBack);
executeAjax('/get_file_list.asmx',blah, blah, blah, successCallBack2,errorCallBack2);
executeAjax('/get_assigned_to_list.asmx',blah, blah, blah, successCallBack3,errorCallBack3);
executeAjax('/get_comments_list.asmx',blah, blah, blah, successCallBack4,errorCallBack4);
Following is the log from the java script page. It includes timestamp before sending the request and time stamp after response is received for each request.
before GET_PARENT_LIST:::::::::::::: 17/05/2018 11:15:39.218
before GET_FILE_LIST:::::::::::::: 17/05/2018 11:15:39.220
before GET_ASSIGNED_TO_LIST:::::::::::::: 17/05/2018 11:15:39.222
before GET_COMMENTS_LIST:::::::::::::: 17/05/2018 11:15:39.224
response of GET_PARENT_LIST:::::::::::::: 17/05/2018 11:15:39.570
response of GET_FILE_LIST:::::::::::::: 17/05/2018 11:15:39.799
response of GET_COMMENTS_LIST:::::::::::::: 17/05/2018 11:15:40.340
response of GET_ASSIGNED_TO_LIST:::::::::::::: 17/05/2018 11:15:40.797
Following is the log from webservices:
start of GET_PARENT_LIST:::::::::: 17/05/2018 11:15:39.223
end of GET_PARENT_LIST:::::::::: 17/05/2018 11:15:39.564
start of GET_FILE_LIST:::::::::: 17/05/2018 11:15:39.733
end of GET_FILE_LIST:::::::::: 17/05/2018 11:15:39.791
start of GET_COMMENTS_LIST:::::::::: 17/05/2018 11:15:40.244
end of GET_COMMENTS_LIST:::::::::: 17/05/2018 11:15:40.336
start of GET_ASSIGNED_TO_LIST:::::::::: 17/05/2018 11:15:40.743
end of GET_ASSIGNED_TO_LIST:::::::::: 17/05/2018 11:15:40.793
Thus, I have a few queries here:
Web service processing for GET_PARENT_LIST was completed on 39.564. Processing of next webservice(GET_FILE_LIST) started at 39.733. Why does it take (733 - 564) 169 milliseconds to start processing of GET_FILE_LIST after GET_PARENT_LIST finished its execution even when all the four ajax calls were already fired by the time first GET_PARENT_LIST was completed of its execution?
It can be observed that, the web services are executed in a way that, execution of next web service starts only after its previous web service has finished execution. Can the web services be run in a way that, they start the execution as soon as they receive the request from ajax calls?
PS: I am running the page and the server on same port locally. So the request is not cross browser and is being run on localhost.
Upvotes: 0
Views: 3964
Reputation: 364
IIS uses worker threads. Each worker thread is responsible for execution of a request per thread. If all the worker threads are full, the next request will have to wait for a worker thread to be free before it can be processed.
There is only one Worker Thread on your Application Pool for IIS Express. That means that it will execute one synchronous call at a time. the others requests are queued.
Updated - Not recommended. You can increase the worker threads by altering the applicationhost.config located in Documents\IISExpress\config\applicationhost.config.
Search for the applicationPools element.
Alter the following by adding a processModel element to the add element to alter the app pool for all .NET 4 web applications:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true">
<processModel maxProcesses="10"/>
</add>
Alter the maxProcesses attribute in following element for default of the app pools to alter every app pool created afterwards (may never need to do this).
<applicationPoolDefaults managedRuntimeLoader="v4.0" >
<processModel maxProcesses="10" />
</applicationPoolDefaults>
You will have to restart the IIS express service for the chances to take affect. This can be done by closing IIS in the system tray, or by restarting Visual Studio.
Warning: A change to the configuration file could make IIS Express unstable since you are altering the attended design of the service.
To make the web service asynchronous, you will have to use a asynchronous pattern. When using the asynchronous pattern on a web service, it is capable of up to 30,000 request per second on each worker thread.
Upvotes: 3