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.