【问题标题】:WCF net.tcp windows service - call duration and calls outstanding increases over timeWCF net.tcp Windows 服务 - 呼叫持续时间和未完成呼叫随时间增加
【发布时间】:2010-03-30 14:11:29
【问题描述】:

我有一个 Windows 服务,它使用 ServiceHost 类通过 net.tcp 绑定来托管 WCF 服务。我对配置进行了一些调整以限制会话和连接数,但似乎每隔一段时间我的“未完成呼叫”和“呼叫持续时间”就会上升并保持在 perfmon 中。在我看来,我在某处有泄漏,但我拥有的代码都相当少,我依靠 ServiceHost 来处理细节。

这是我开始服务的方式

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

我的错误事件只是执行以下操作(或多或少,删除了日志记录等)

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

这是我的 app.config 中的一些 sn-ps,用于显示我尝试过的一些事情

<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" />

显然有一些资源被占用了,但我认为我的配置涵盖了所有内容。我只获得了大约 150 个客户,所以我认为我不会达到我的“300”限制。 “每秒调用次数”在每秒 2-5 次调用之间保持不变。该服务将运行数小时和数小时,其中 0-2 个“未完成的呼叫”和非常低的“呼叫持续时间”,然后最终它将达到 30 个未完成的呼叫和 20 秒的呼叫持续时间。

关于什么可能导致我的“未完成通话”和“通话时长”飙升的任何提示?我在哪里泄漏?为我指明正确的方向?

【问题讨论】:

    标签: c# .net wcf network-programming net.tcp


    【解决方案1】:

    调用服务时,您正在执行的代码可能效率低下。没有看到这一点,很难真正诊断。

    【讨论】:

    • 迟到总比没有好,但结果确实如此。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多