schglurps
schglurps

Reputation: 1387

Improve WCF service performance

My company owns a server with 24 cores and a lot a RAM inside. The OS is Windows 2008 R2 SP1. I deployed on this server a WCF application, hosted in IIS. On the same server I installed a multithreaded client which calls one of the WCF service, as often as possible. I encountered a bottleneck : all the cores on the server are used, but at a very low level, so the CPU consumption doesn't exceed 10 %. My WCF service is configured like this :

  <system.serviceModel>
<services>
  <service behaviorConfiguration="myBehavior" name="...">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="myBinding" bindingNamespace="..." contract="..."/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="myBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <netTcpBinding>
    <binding name="myBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647">
      <security mode="None">
        <message clientCredentialType="None"/>
        <transport protectionLevel="None" clientCredentialType="None"/>
      </security>
      <reliableSession enabled="false"/>
      <readerQuotas maxDepth="64" maxStringContentLength="204800" maxArrayLength="204800" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
    </binding>
  </netTcpBinding>
</bindings>

My service has also the following attributes : InstanceContextMode.Single and ConcurrencyMode.Multiple. Did anyone encounter a similar problem ? I searched the solution for days, but I didn't find it yet :(

Thank you in advance !

Upvotes: 1

Views: 1849

Answers (1)

Sixto Saez
Sixto Saez

Reputation: 12680

I'm not sure how you're measuring the performance bottleneck but no matter how many client calls you generate, the service will only handle 200 calls at a time. The netTcpBinding is uses sessions so the throttle there is the maxConcurrentSessions="200" setting. You've configured the service as a multi-threaded singleton which is limited to 200 simultaneous calls by the maxConcurrentCalls="200" setting. The CPU load will also depend on how much work is performed during each call and whether it is IO bound or not. Review the serviceThrottling element documentation and try increasing both settings to see if your throughput improves.

If your sevice implementation allows, I would recommend you try configuring the service with InstanceContextMode.PerSession and ConcurrencyMode.Single to compare throughput with your current configuration. IIS 7x hosts WCF services using the Windows Process Activation Service (WAS). WAS is designed to handle concurrency. A singleton configuration negates the value of using WAS.

Upvotes: 4

Related Questions