[WCF]Things that will impact concurrency & capacity behavior of WCF service (with simoultaneous client requests/connections)

[WCF]Things that will impact concurrency & capacity behavior of WCF service (with simoultaneous client requests/connections)

I have found that many guys have encountered some concurrent connection limit problems when calling WCF service in their .NET application. Here are some information that may help resolve such kind of problems:

1. Operating system inbound connection limitation

Windows client operating system such as XP and Vista has inbound connection limitation. Threrefore, if your network based service is hosted on such kind of operating system, you do need to take care of such limitation.

#Inbound connections limit in Windows XP

https://support.microsoft.com/kb/314882

2. .NET application max outbound connection limitation(per appdomain)

For .NET framework based application, there is a per-appdomain outbound connection limitation(default 2 for each remote server). We can adjust it via the “system.net/connectionManagement” configuration section.

#<connectionManagement> Element (Network Settings)

https://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx

Also, for ASP.NET 2.0 application, there is something else we need to take care:

#Contention, poor performance, and deadlocks when you make Web service requests from ASP.NET applications

https://support.microsoft.com/kb/821268

#MaxConnection does not have effect on ASP.NET 2.0

https://blogs.msdn.com/carloc/archive/2008/03/31/maxconnection-does-not-have-effect-on-asp-net-2-0.aspx

3. WCF specific concurrent connection limitation

After we’ve eliminated all the OS and .NET standard network issues, there comes to the WCF specific settings that restrict concurrent WCF client requests.

WCF provide some service level settings that can restrict the concurrent connection behavior from WCF clients. Also, such settings also somewhat rely on the Instance and session mode the service is using. The following config fragment has demonstrated the three attributes that mainly affect the service throttling behavior:

<behavior name="[service behavior name]">

  <serviceThrottling

    maxConcurrentCalls="10"

    maxConcurrentInstances="1"

    maxConcurrentSessions="16"

    />

</behavior>

And here is the description from MSDN document:

Attribute

Description

maxConcurrentCalls

A positive integer that limits the number of messages that currently process across a ServiceHost. Calls in excess of the limit are queued. Setting this value to 0 is equivalent to setting it to Int32.MaxValue. The default is 16.

maxConcurrentInstances

A positive integer that limits the number of InstanceContext objects that execute at one time across a ServiceHost. Requests to create additional instances are queued and complete when a slot below the limit becomes available. The default is Int32.MaxValue.

maxConcurrentSessions

A positive integer that limits the number of sessions a ServiceHost object can accept.

The service will accept connections in excess of the limit, but only the channels below the limit are active (messages are read from the channel). Setting this value to 0 is equivalent to setting it to Int32.MaxValue. The default is 10.

#<serviceThrottling>

https://msdn.microsoft.com/en-us/library/ms731379.aspx

Also, if you want to get more on these settings, here is a blog entry which provide more explanation:

#Throttling in WCF

https://kennyw.com/indigo/150

https://blogs.msdn.com/wenlong/archive/2008/04/21/wcf-request-throttling-and-server-scalability.aspx