开发者

WCF named pipes service settings

Is it worth to set the service with ConcurrencyMode.Multiple and InstanceContextMode.Single attributes to 开发者_JAVA技巧save some performance when using named pipes ?

I mean when I do so I have to bother with multithreading issues.


I automatically use ConcurrencyMode.Multiple for my WCF services, because I normally expect a service to be able to handle multiple requests at the same time. To me, this seems like the most intuitive behaviour for a service (ie: it would be strange if I called a web service and had to wait for 10 outstanding requests from other users before I was attended to).

Using ConcurrencyMode.Single forces the service to process a single request at a time (in the event of multiple requests they are queued). This, potentially, will slow requests down.

But it depends on what each request does. Simple math calculations or string manipulations going to be so fast that the overhead of WCF will be your main bottleneck. If your service queries or modifies some sort of database, the time to do the database operation is likely to be your bottleneck. But if the database is small, or your only expecting a small number of clients, you'll probably never notice the difference. If you're pulling data from 5 web services and doing some complex merging operations, this might be a problem.

Unless you know you'll have multiple simultaneous requests, run with ConcurrencyMode.Single until some sort of objective performance criteria cannot be met. Then, you'll need to do the usual benchmarking to figure out what part of your service is the slowest. Speed that bit up. If it happens that ConcurrencyMode.Single is the slow bit, go for multiple instead!


Is it worth it? That depends on how much you value the performance gain, compared to how difficult it is to implement.

How good is the performance gain? That depends on the application. Only you can answer that question by measuring.

As always with performance, you must measure.

If it's fast enough already, don't bother.

If it isn't fast enough, measure where the application spends its time. In most applications that involve out-of-process resource access (e.g. database access), the bottleneck is here, rather than in a WCF service's InstanceContextMode.

However, you don't write what kind of application is your WCF service, so it may make a difference in your case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜