WCF services expose numerous configuration parameters that affect performance. This topic provides general guidance for setting optimal values for these configuration parameters to improve performance of WCF services.
Implement
serviceThrottling behavior for backend WCF services. Service throttling
allows you to even out the load on your backend WCF servers and to
enforce resource allocation. serviceThrottling behavior for backend WCF
services is configured by modifying the values for the maxConcurrentCalls, maxConcurrentSessions, and maxConcurrentInstances parameters in the config file for the WCF service. Set maxConcurrentCalls, maxConcurrentSessions, and maxConcurrentInstances to a value greater than 16 * the number of CPUs or CPU cores. For example, on a computer with 8 CPU cores, set maxConcurrentCalls, maxConcurrentSessions, and maxConcurrentInstances to a value greater than 128 (16 * 8 = 128) as follows:
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200" />
The NetTcpBinding.ListenBacklog property controls the maximum number of queued connection requests that can be pending for a Web service. The NetTcpBinding.MaxConnections
property controls the maximum number of connections to be pooled for
subsequent reuse on the client and the maximum number of connections
allowed to be pending dispatch on the server. Each of these properties
uses a default value of 10 which may be suboptimal, especially for
document processing scenarios that require high throughput.
Consider increasing the default value of these properties for high-throughput, document-processing scenarios that use WCF services which implement the netTcpBinding binding class.
In the following example, both the listenBacklog and maxConnections parameters are set to a value of “200”.
For more information about the NetTcpBinding.ListenBacklog property, see NetTcpBinding.ListenBacklog Property (http://go.microsoft.com/fwlink/?LinkId=157752) on MSDN.
For more information about the NetTcpBinding.MaxConnections property, see NetTcpBinding.MaxConnections Property (http://go.microsoft.com/fwlink/?LinkID=157751) on MSDN.
Consider increasing the default value of these properties for high-throughput, document-processing scenarios that use WCF services which implement the netTcpBinding binding class.
In the following example, both the listenBacklog and maxConnections parameters are set to a value of “200”.
<netTcpBinding> <binding name="netTcpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="200" maxBufferPoolSize="1048576" maxBufferSize="10485760" maxConnections="200" maxReceivedMessageSize="10485760"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="None"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> <message clientCredentialType="Windows" /> </security> </binding> </netTcpBinding>
For more information about the NetTcpBinding.MaxConnections property, see NetTcpBinding.MaxConnections Property (http://go.microsoft.com/fwlink/?LinkID=157751) on MSDN.
By
default, several ASP.NET httpModules are defined in the Request
Pipeline in IIS 6.0 and in the Classic or Integrated Pipeline in IIS
7.0. These components intercept and process all incoming requests. The
default modules are defined in the web.config file contained in the
%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG folder for 32-bit
ASP.NET applications and in the
%windir%\Microsoft.NET\Framework64\v2.0.50727\CONFIG folder for 64-bit
ASP.NET applications, as shown by the following snippet.
In most scenarios it is not necessary to load all of these
modules. Therefore, it is possible to improve performance by eliminating
the following httpModules when running WCF Web services:
<httpModules> <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/> <add name="Session" type="System.Web.SessionState.SessionStateModule"/> <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/> <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/> <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/> <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/> <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/> <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/> <add name="Profile" type="System.Web.Profile.ProfileModule"/> <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </httpModules>
- Session
- WindowsAuthentication
- FormsAuthentication
- PassportAuthentication
- RoleManager
- AnonymousIdentification
- Profile
The WCF Module/Handler Registration Tool is available for download at http://go.microsoft.com/fwlink/?LinkId=157593
(http://go.microsoft.com/fwlink/?LinkId=157593). This utility can be
used to install, list, or configure the following WCF modules:
- WCF Synchronous HTTP module and handler
- WCF Asynchronous HTTP module and handler
- WCF HTTP module and handler
No comments:
Post a Comment