codecompleting
codecompleting

Reputation: 9611

WCF concurrency model confusion

I'm reading this msdn page which says the concurrency model defaults to single: http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.concurrencymode.aspx

Yes this page makes it seem like a new instance is created per client: http://msdn.microsoft.com/en-us/magazine/cc163590.aspx (see per-call services heading):

"Per-call services are the Windows Communication Foundation default instantiation mode. When the service type is configured for per-call activation, a service instance, a common language runtime (CLR) object, exists only while a client call is in progress. Every client request gets a new dedicated service instance."

Am I reading this wrong?

BTW I am hosting my WCF in a windows service.

Is it single or multiple?

Upvotes: 1

Views: 1082

Answers (2)

granaker
granaker

Reputation: 1328

look at this article: http://msdn.microsoft.com/en-us/library/ms731193.aspx

"In PerCall instancing, concurrency is not relevant, because each message is processed by a new InstanceContext"

Upvotes: 2

villecoder
villecoder

Reputation: 13493

There's a good explanation of what's going on over on CodeProject. Here is the URL: http://www.codeproject.com/Articles/89858/WCF-Concurrency-Single-Multiple-and-Reentrant-and

Long story short, it's a combination of both InstanceMode and Concurrency. The default setup is to use a PerCall for InstanceMode and Single for Concurrency. The net effect:

  • A new instance of the object servicing your requests is created for each call to the service (PerCall)
  • Your service will only use one thread to service requests at a time (Single).

Don't confuse this with InstanceMode = Singleton and ConcurrencyMode = Multiple or Reentrant, in which one instance serves multiple requests on multiple threads.

Upvotes: 3

Related Questions