WCF - Processing Request from Multiple Clients

My WCF services library is hosted as a Windows service and is designed to handle requests from multiple clients. One request that customers are going to make often is quite resource intensive.

I have two doubts regarding the above scenerio:

  • How does the WCF service handle multiple client requests?
  • Is there any WCF configuration to make the process efficient?

Thanks!

+5
source share
1 answer

In the default scenario, the WCF service host (the subject that hosts your service class) will create a new instance of your service class for each incoming request and allow you to process the request (activation "per call").

, serviceThrottling .

<system.serviceModel>
   <behaviors>
      <serviceBehaviors>
         <behavior name="ThrottledServiceBehavior">
            <serviceThrottling 
                maxConcurrentCalls="25" 
                maxConcurrentSessions="25"
                maxConcurrentInstances="25"/>
         </behavior>
      </serviceBehaviors>
   </behaviors>

Kenny Wolf .

, InstanceContextMode ConcurrencyMode ( ) , concurrency .

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, 
                 ConcurrencyMode=ConcurrencyMode.Single)]
class YourServiceClass : IYourService
{
  .....
}

InstanceContextMode PerCall ( ), ConcurrencyMode Single ( ).

InstanceContextMode PerSession, , ( ), Single ( - , , , !).

ConcurrencyMode Reentrant ( ) Multiple ( - !).

+11

All Articles