ConcurrencyMode? InstanceContextMode?

Topics: Web Api
Dec 8, 2011 at 9:39 PM

Hi,

I wanted to know if these options (ConcurrencyMode? InstanceContextMode?) are available for WebAPI, and if so, what are their defaults?

I would like to know whether the service I wrote is currently restricting itself to one concurrent call or not.

Thanks,

Andrew

Coordinator
Dec 9, 2011 at 11:38 PM

We don’t do anything special here - we just use the WCF defaults:

http://msdn.microsoft.com/en-us/library/ms731193.aspx

Daniel Roth

Dec 10, 2011 at 6:17 AM

Hi Daniel,

From what I can tell, the defaults appear to be:

ConcurrencyMode.Single (http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.concurrencymode.aspx)
InstanceContextMode.PerSession (http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.instancecontextmode.aspx)
SessionMode.Allowed (I think? http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.sessionmode.aspx)

This would seem to mean by default concurrent requests from the same client (as defined by a .Net session cookie) are not allowed.

Handling multiple clients concurrently though seems to be allowed?

I may have to run some tests on my service, as I cannot tell whether performance improves that much when I explicitly set ConcurrencyMode.Multiple and InstanceContextPerMode.PerCall, which would make the service entirely stateless as intended (and provide the best concurrency).