WCF throttling provides some properties that we can use to limit how many instances or sessions are created at the application level. Performance of the WCF service can be improved by creating proper instance.
When
WCF was first released in .NET Framework 3.0, the default values for
WCF
Service throttling settings such as MaxConcurrentSessions and MaxConcurrentCalls
were set very conservatively. For example, here are the default settings in
3.0:
- MaxConcurrentSessions
(default: 10)
- MaxConcurrentCalls
(default: 16)
- MaxConcurrentInstances
(default: 26)
Attribute | Description |
---|---|
maxConcurrentCalls | Limits the total number of calls that can currently be in progress across all service instances. The default is 16. |
maxConcurrentInstances | The number of InstanceContext objects that execute at one time across a ServiceHost. The default is Int32.MaxValue. |
maxConcurrentSessions | A positive integer that limits the number of sessions a ServiceHost object can accept. The default is 10. |
Service Throttling can be configured either Adminstractive or Programatically
Administrative(configuration file)
Using <serviceThrottling> tag of the
Service Behavior, you can configure the maxConcurrentCalls, maxConcurrentInstances ,
maxConcurrentSessions property as shown below.
<system.serviceModel> <services > <service behaviorConfiguration="ServiceBehavior" name="MyService"> <endpoint address="" binding="wsHttpBinding" contract="IMyService"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true "/> <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances ="100" maxConcurrentSessions ="200"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
References
- Nice information on throttling details
by Mr. Kenny Wolf: http://kennyw.com/work/indigo/150.
- Nice article by Mr. Rick Rain in three parts which explains concurrency and
throttling in depth: http://blogs.msdn.com/b/rickrain/archive/2009/06/15/wcf-instancing-concurrency-and-throttling-part-1.aspx.
- Mr. Michele Leroux Bustamante talks about settings which influence how
throughput of WCF services can be increased
using WCF concurrency: http://www.windowsitpro.com/article/net-framework2/concurrency-and-throttling-configurations-for-wcf-services.aspx.
- Justin Smith explains a sample code on how
InstanceContextMode
and ConcurrencyMode
affect concurrency: http://www.wintellect.com/CS/blogs/jsmith/archive/2006/05/16/instancecontextmode-and-concurrencymode.aspx.
- Mr. Glav talks about throttling and
legacy systems: http://weblogs.asp.net/pglavich/archive/2007/06/27/wcf-and-concurrent-usage-throttling.aspx.
- Default values for WCF throttling: http://blogs.msdn.com/b/wenlong/archive/2009/07/26/wcf-4-higher-default-throttling-settings-for-wcf-services.aspx.
- http://wcftutorial.net/WCF-Throttling.aspx
No comments:
Post a Comment