Return to HomePage




How To: Tune Web Services

Source: http://msdn.microsoft.com/library/en-us/dnpag/html/scalenetchapt17.asp
J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman


ASP.NET Web services use the same ASP.NET runtime as ASP.NET applications. As a result, the tuning guidelines discussed for ASP.NET apply to Web services. For Web services, there are a number of additional considerations.
Tuning Options
Consider the following tuning options:
* Tune the thread pool using the formula for reducing contention.
* Configure maxconnections.
* Prioritize and allocate connections across discrete Web services.
* Consider the responseDeadlockInterval Attribute.
* If you upload large files, configure maxRequestLength.

Tune the Thread Pool Using the Formula for Reducing Contention
You should tune the thread pool and connection settings on any ASP.NET server that calls other Web services. For a detailed explanation of how to configure maxconnection in relation to other settings such as maxWorkerThreads, and maxIoThreads, see "Threading" in Chapter 10, "Improving Web Services Performance" and "Thread Pool Attributes" in "ASP.NET Tuning" in this chapter.
Configure maxconnections
The maxconnection attribute in Machine.config limits the number of concurrent outbound calls.

Note: This setting does not apply to local requests — requests that originate from ASP.NET applications on the same server as the Web service. The setting applies to outbound connections from the current computer, for example to ASP.NET applications and Web services calling other remote Web services.

The default setting for maxconnection is 2 per connection group. For desktop applications that call Web services, two connections may be sufficient. For ASP.NET applications that call Web services, two is generally not enough. Change the maxconnection attribute from default of 2 to (12 x #CPUs) as a starting point.

<connectionManagement>
		  <add address="*" maxconnection="12"/>
	
</connectionManagement>

Note that 12 connections x #CPUs is an arbitrary number, but empirical evidence has shown that it is optimal for a variety of scenarios, when you also limit ASP.NET to 12 concurrent requests. You need to validate the appropriate number of connections for your scenario.
Increasing the maxconnection attribute results in increased thread pool and processor utilization. With the increase in the maxconnection value, a higher number of I/O threads will be available to make outbound concurrent calls to the Web service. As a result, incoming HTTP requests are processed at a faster pace.
Before Making the Change
You should consider increasing the connections only if you have available CPU. You should always check processor utilization before considering the increase in the attribute, because increasing the attribute results in more processing work for the processor as described earlier. Therefore, increasing this attribute makes sense only when you have processor utilization below the threshold limits (such as 75 %).
For more information, see “ASP.NET Tuning” in this chapter.
Evaluating the Change
Changing the attribute may involve multiple iterations for tuning and involves various tradeoffs with respect to thread pool utilization. Therefore, the changes in the maxconnection attribute may require changes to other thread pool – related configuration attributes such as maxWorkerThreads, and maxIoThreads.
When you load test your application after making the configuration changes, you should monitor CPU utilization and watch the ASP.NET Applications\Requests/sec and ASP.NET Applications\Requests in Application Queue performance counters. Requests in Application Queue should decrease, while Requests/sec and CPU utilization should increase.
Prioritize and Allocate Connections Across Discrete Web Services
Enumerate and prioritize the Web services you call. Allocate more connections to your critical Web services. You specify each Web service by using the address attribute as follows.

<connectionManagement>
		    <add address="WebServiceA" maxconnection="8">
		    <add address="WebServiceB" maxconnection="4">
	
</connectionManagement>

For example, if your application typically makes more requests to Web ServiceA than WebServiceB, you can dedicate more connections, as shown in the example.
Consider the responseDeadlockInterval Attribute
When making Web service calls from an ASP.NET application, if you are increasing the value of both the proxy timeout and the executionTimeout to greater than 180 seconds for some reason, you should consider changing the responseDeadlockInterval attribute for processModel element in the machine.config file. The default value of this attribute is 180 seconds. If there is no response for an executing request for180 seconds, the ASP.NET worker process will recycle.
You must reconsider your design if it warrants changing the attributes to a higher value.
If You Upload Large Files, Configure maxRequestLength
The ASP.NET runtime settings prevent you from uploading files larger than 4 MB. To change this default, you need to modify the maxRequestLength parameter in the <httpRuntime> section to the value that you require.

More Information
For more information, see the following resources:
* "Bulk Data Transfer" in Chapter 10, "Improving Web Services Performance"
* Knowledge Base article 295626, "PRB: Cannot Upload Large Files When You Use the HtmlInputFile Server Control," at http://support.microsoft.com/default.aspx?scid=kb;en-us;.295626




Return to HomePage
Microsoft Communities