I have a singleton WCF service that owns sockets that are used to communicate with an external party. I am using .NET 3.5 SP1
The code is thread safe and scales well.
When I run this code in a WCF service hosted in IIS 7.5 on Windows 2008 R2 64 bit, the WCF service cannot accept more than one concurrent call.
My service class implements three interfaces, each with a standard ServiceContract attribute and only a namespace, no other settings
I have the following attribute on the class:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single,
ConcurrencyMode = ConcurrencyMode.Multiple)]
I have the following behavior configuration:
<behavior name="MyServiceAsyncBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceThrottling maxConcurrentCalls="60" maxConcurrentSessions="60"
maxConcurrentInstances="60" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
I created a seperate application, used the exact same configuration file (literally a copy, no changes were made to it), and a singleton service class with the exact same ServiceBehavior attribute on the class. This service DOES NOT exhibit the same behavior, it happily allows concurrent calls.
The only differences between the test service that allows concurrent calls and the real service that does not is that the real service owns worker threads and TCP sockets, and implements three interfaces instead of one.
What am I missing here?
I found the issue. It relates to the remote TCP service. I was using an ill-behaved test service, which never returned to the caller.
WCF seems to have prevented concurrent calls to the singleton because the singleton was locked in a tight loop