Why can a WCF service handle more calls from different processes than from a thread

Why are WCF services configured with instance for each call and multiple concurrency working differently when started with a different process and completely different when called from threads?

I have one application that distributes data by the number of threads and makes calls (don’t think that the lock is happening in the code, check it again) to the WCF service. During the test, it was noticed that increasing the number of threads in the distribution application does not increase the overall performance of the wcf processing service, on average, about 800 m / min (message processing per minute), so the throughput really does not change, but if you run the second application, then the average throughput increases to ~ 1200 m / min.

What am I doing wrong? what did I miss? I do not understand this behavior.

UPDATE # 1 (answer to questions in the comments)

Thanks for such quick answers. The maximum number of connections is set to 1000 in the configuration (yes in system.net). Referring to this wcf article Instances and Streams , the maximum calls should be 16 x the number of cores, so I assume that if ~ 30 threads per 2 cpu form is called, should the wcf service accept basically all of these streaming calls?

Does this have anything to do with shared memory? because these are probably the only differences between multiple threads and processes. I think so.

You do not have the opportunity right now to test it with a large number of processors or a single. Will do when it can.

+5
source share
2 answers

So, I think, in order to understand this behavior, you first need to understand how WCF handles calls with an instance for each call. The prompt is indicated in the name - for the call.

Each call that any client makes is serviced by a new instance of the service (the exception is reconnection, but this is not important in your scenario).

Thus, the concurrency service setup has no practical differences regarding the behavior of the service. Regardless of whether calls come from one multi-threaded client or several clients, the service will behave the same: it will create an instance of the service for each call.

Therefore, the difference in overall system performance must be related to something on the client side. If I had to guess, I would say that one client is slower than two clients because of the cost associated with switching the context , which (through an unidentified mechanism), starting the client in two separate processes.

If I'm right, you should be able to get the maximum performance in the stream by running several single-threaded clients, which is a test you can do.

0
source

In this implementation of the operation below, the attribute must be added to the class.

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)] public class MyService : IMyService { } 

You can read more here: http://wcftutorial.net/Per-Call-Service.aspx

0
source

All Articles