An area you'll want to take a look at when building a WCF service is service throttling. Throttling refers to the number of sessions, calls, and/or service instances that are available at any given time. Here is an example of how throttling is configured in a configuration file:
<system.servicemodel>
<behaviors>
<serviceBehaviors>
<behavior name="throttling">
<serviceThrottling maxConcurrentCalls="10" maxConcurrentInstances="10" maxConcurrentSessions="10"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.servicemodel>Here are what the attributes in the serviceThrottling element represent:
Here is what I think is a good example of how this works in practice:
I could potentially have a service with an InstanceContextMode set to PerCall (meaning a new service instance is created for every call), and have the following throttling values:
Let's imagine I have 30 clients hitting my service at the same time. In this case the service can handle all the requests, but it might be a little slow because I have told my service via the throttling configuration that it is only to deal with 1 concurrent call at a time and it is only to create one instance. This will result in a "queue" of requests in my service that essentially get handled one at a time. In practice, it seems as though maxConcurrentCalls and maxConcurrentInstances control how fast your service responds, while if you have maxConcurrentSessions set too low you can pretty much bring down your service because it gets overwhelmed with requests (I have seen this occur when hosting a service in a console application but haven't tried it when hosting in IIS). Also, keep in mind that a session is preserved until the client closes their connection to the service or until the timeout for their connection lapses (the binding timeout can be set via the configuration file on both the client and server--and the shorter timeout wins). Given the ability to set the timeout value for a connection via the server configuration file, if you set this timeout very low then you can protect your server from being taken down--provided a low timeout value works for your application.