views:

72

answers:

3

How do I maximize performance for my wcf service? Is it possible to take advantage of multicore? or multi-threading?

Thanks!!

A: 

This is a very broad question that is difficult to answer. It will depend on what your service is doing and how it is implemented. But as a general rule of thumb you should avoid long running operations which could monopolize worker threads.

Darin Dimitrov
A: 

If you host your WCF service in IIS, then IIS will place each call on it's own thread, giving you the advantage mulitcores on your server.

If you want a single call to run on many threads, then you need to program this yourself in your code. You would only need this if your service is doing a lot of calculations.

Shiraz Bhaiji
Only if you add the following attribute to the service implementation [ServiceBehavior(ConcurrencyMode = ConcurencyMode.Multiple)].
Przemek
Thanks, Shiraz. My services are self-hosted. How can I place each call in it's own thread for self hosted?
Jacko
+1  A: 

The following Behavior properties default to the simplest (single threaded) solution, changing them from their default values will give you multiple threading, including self-hosted services.

You may want to also look at InstanceContextMode also this MSDN article gives a starting point on WCF Concurrency.

Dog Ears
Thanks, Dog Ears.
Jacko