WCF net.tcp windows service - call duration and calls outstanding increases over time

Posted by Brook on Stack Overflow See other posts from Stack Overflow or by Brook
Published on 2010-03-30T14:11:29Z Indexed on 2010/03/30 14:13 UTC
Read the original article Hit count: 1376

Filed under:
|
|
|
|

I have a windows service which uses the ServiceHost class to host a WCF Service using the net.tcp binding. I have done some tweaking to the config to throttle sessions as well as number of connections, but it seems that every once in a while my "Calls outstanding" and "Call duration" shoot up and stay up in perfmon. It seems to me I have a leak somewhere, but the code I have is all fairly minimal, I'm relying on ServiceHost to handle the details.

Here's how I start my service

ServiceHost host = new ServiceHost(type);
host.Faulted+=new EventHandler(Faulted);
host.Open();

My Faulted event just does the following (more or less, logging etc removed)

if (host.State == CommunicationState.Faulted)
{
  host.Abort();
}
else
{
  host.Close();
}
host = new ServiceHost(type);
host.Faulted+=new EventHandler(Faulted);
host.Open();

Here's some snippets from my app.config to show some of the things I've tried

<runtime>
  <gcConcurrent enabled="true" />
  <generatePublisherEvidence enabled="false" />
</runtime>
.........
<behaviors>
  <serviceBehaviors>
    <behavior name="Throttled">
      <serviceThrottling
        maxConcurrentCalls="300"
        maxConcurrentSessions="300"
        maxConcurrentInstances="300"
      />
..........
<services>
  <service name="MyService" behaviorConfiguration="Throttled">
    <endpoint address="net.tcp://localhost:49001/MyService"
              binding="netTcpBinding"
              bindingConfiguration="Tcp"
              contract="IMyService">
    </endpoint>
  </service>
</services>
..........
<netTcpBinding>
    <binding name="Tcp" openTimeout="00:00:10" closeTimeout="00:00:10" portSharingEnabled="true"
             receiveTimeout="00:5:00" sendTimeout="00:5:00" hostNameComparisonMode="WeakWildcard"
             listenBacklog="1000"
             maxConnections="1000">
      <reliableSession enabled="false"/>
      <security mode="None"/>

    </binding>
  </netTcpBinding>
..........
<!--for my diagnostics-->
<diagnostics performanceCounters="ServiceOnly" wmiProviderEnabled="true" />

There's obviously some resource getting tied up, but I thought I covered everything with my config. I'm only getting about ~150 clients so I don't think I'm coming up against my "300" limit. "Calls per second" stays constant at anywhere from 2-5 calls per second. The service will run for hours and hours with 0-2 "calls outstanding" and very low "call duration" and then eventually it will shoot up to 30 calls oustanding and 20s call duration.

Any tips on what might be causing my "calls outstanding" and "call duration" to spike? Where am I leaking? Point me in the right direction?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wcf