Compartir a través de


WCF 4: Higher Default Throttling Settings for WCF Services

It has been quite a while that I did not write anything. This is because I was fully focusing on WCF 4. Now that we have got most of the work done, it is good time to continue my writing. Starting from this blog entry, I will show you performance related changes in WCF 4. Please let me know what you think about WCF performance and what you would like to see in future releases.

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)

These settings are not enough for many real production environments. With limited concurrency due to the low settings, the power of the production server is normally not well utilized. So people have to bump up these values for enterprise applications. However, it is hard for people to figure out how to set these values correctly. Most people would set very high numbers or even int.MaxValue to workaround the throttling which defeats the purpose of the throttling. The main purpose for the throttling settings can be classified into the following two aspects:

1) Controlled resource usage: With the throttling of concurrent execution, the usage of resources such as memory or threads can be limited to a reasonable level so that the system works well without hitting reliability issues.

2) Balanced performance load: Systems always work in a balanced way when the load is controlled. If there are too much concurrent execution happening, a lot of contention and bookkeeping would happen and thus it would hurt the performance of the system.

In WCF 4, we have revised the default values of these settings so that people don’t have to change the defaults in most cases. Here are the main changes:

· MaxConcurrentSessions: default is 100 * ProcessorCount

· MaxConcurrentCalls: default is 16 * ProcessorCount

· MaxConcurrentInstances: default is the total of the above two, which follows the same pattern as before.

Yes, we use the multiplier “ProcessorCount” for the settings. So on a 4-proc server, you would get the default of MaxConcurrentCalls as 16 * 4 = 64. The basically consideration is that, when you write a WCF service and you use the default settings, the service can be deployed to any system from low-end one-proc server to high-end such as 24-way server without having to change the settings. So we use the CPU count as the multiplier.

We also bumped up the value for MaxConcurrentSessions from 10 to 100. Based on customer’s feedback, this change fits the need for most applications.

Please note, these changes are for the default settings only. If you explicitly set these settings in either configuration or in code, the system would use the settings that you provided. No “ProcessCount” multiplier would be applied.

Comments

  • Anonymous
    July 26, 2009
    Great move. I have lost count on the number of times I’ve helped customers and colleagues with WCF “performance problems” due to the default throttling settings. :-) Anders Lybecker

  • Anonymous
    April 22, 2010
    Good to see the modified default values I was struggling to find out the best values for my 3.5 WCF service. Well now i can use these settings. I have one question regarding WCF timeout settings, hope so you can help me on that. Is there anyway where i can close my service channel after certain amout of time. If my channel is into fault state then how can i close that channel. I am using the proxy generated by svcutil. Regards, Harish

  • Anonymous
    November 22, 2010
    I don't really get the "MaxConcurrentInstances" config. Will it be: ("MaxConcurrentSessions" + "MaxConcurrentCalls") * ProcessorCount ??? Thanks, you post was really helpful!

  • Anonymous
    December 09, 2010
    how come the latest documentation still says ServiceThrottle.MaxConcurrentSessions defaults to 10? msdn.microsoft.com/.../system.servicemodel.dispatcher.servicethrottle.maxconcurrentsessions.aspx

  • Anonymous
    February 28, 2011
    I also have the same question as what jlamkw asked. But I also found another article on msdn which is saying what you said. Here's the link: msdn.microsoft.com/.../ee790948.aspx This says that the values should be based on the processor count.

  • Anonymous
    December 04, 2011
    Where is the true ? All msdn articles stands that MaxConcurrentSessions defaults to 10 and maxConcurrentCall to 16. Thanks

  • Anonymous
    February 26, 2014
    Hi, Is it possible to set global throttling values for multiple services? For my case I need a global throttling setting per iis that will apply to sum of all of the hosted services. I.e, we host multiple wcf services on a single iis. Say we have 5 different wcf services hosted on the same iis and I want to limit the maxconcurrent call value to 100 per iis. According to my understanding, setting maxConcurrentSessions = 100 and applying this behavior to all 5 services lets the iis have 500 cocurrent sessions under maximum load. Setting maxConcurrentSessions = 20 to have an overall limit of 100 is also no good for me. Because I do not want to limit per service (A single wcf service should allow new sessions if the iis is not fully busy by other services). I.e, I need per iis limits not per service limits. Is it possible to achieve this in wcf when using iis hosting?

  • Anonymous
    December 15, 2015
    Thank you, that helps me a lot. You save me.