Throttling is an important behavior of your WCF service that you should be addressing before publishing your service to clients.
The throttling behavior holds the configuration for 3 limitations that control the amount of resources that your service hosting can allocate to deal with client requests, thus enables you to manage the resource usage and balance the performance load.
It is crucial that you set the behavior appropriately because the default limitations of this service behavior is considered to be quite low.
The reason for such default values was for blocking DOS (Denial of Service) attacks on your service. However, most of the services we build are on-premises services within our enterprise, it is more appropriate to support more clients rather than block malicious attacks of some kind. (The general purpose is to find the right balance between the two, yet, it usually isn't as the default values are.)
Why am I blogging about it just now?
Well, one of the rather unknown changes made in WCF 4.0 is the change of the service throttling behavior default values.
Microsoft realized that the prior default values weren't practical and were seldom applied that way.
The following summarizes the throttling behavior elements and their default value setting.
You should note that "ProcessorCount
" indicates the number of CPU processors at the machine.
- MaxConcurrentCalls
Defines the total number of concurrent calls that the service will accept.
Prior to .NET 4.0 the default value is 16
, whereas in .NET 4.0 the default value is 16 * ProcessorCount
.
In practice, the amount of calls your service will actually handle depends on the concurrency mode your service is configured with.
- MaxConcurrentSessions
Defines the total number of sessionful channels that the service will accept.
Prior to .NET 4.0 the default value is 10
, whereas in .NET 4.0 the default value is 100 * ProcessorCount
.
This setting affects only sessionful channels where a session is represented by each proxy created by the client.
If a client calls through a sessionful channel which needs to be created and the limitation is exceeded, the request will be queued.
- MaxConcurrentInstances
Defines the total number service instances that will be created for servicing requests.
Prior to .NET 4.0 the default value is 26
, whereas in .NET 4.0 the default value is 116 * ProcessorCount
(the sum of the previous two).
In practice, the amount of service instances that will actually be created depends on the instance context mode your service is configured with.
If your service is configured as per-session, the maximum number of instances and sessions will be the minimum value between the MaxConcurrencySessions
and MaxConcurrancyInstances
.
If your service is configured as per-call, the setting limits the number of active service instances. If exceeded, new requests will be queued.
If your service is configured as single, this setting is ignored.
Finally, WCF 4.0 has surely made the default values a bit more practical. In spite of that, I still recommend paying a visit to that behavior and set it differently if needed.
CodeProject