【问题标题】:Why does my client send request so slowly?为什么我的客户发送请求这么慢?
【发布时间】:2010-11-28 02:53:28
【问题描述】:

我有 WCF 客户端向服务发送请求。我的业务代码调用客户端 API 每秒发送 300 多个请求。但是根据我的服务和 WCF ServicePoint 的性能计数器,我的客户只发送了大约 50 个服务。

我在代码中将 ServicePointManager.DefaultConnectionLimit 增加到 1000,并在服务配置文件中将 maxConCurrentCalls 设置为 1000,但几乎没有改进。

我想 WCF 客户端中可能有队列等待发送请求。有什么方法可以配置它并加速我的客户端。

这是我的客户端配置:

<basicHttpBinding>
    <binding name="Binding" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="2000000" maxBufferPoolSize="524288" maxReceivedMessageSize="2000000"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>

【问题讨论】:

  • 一个简单的测试是启动两个并发客户端,看看它们在服务器上产生的命中率是否是服务器的两倍。如果是这样,那就是客户端限制问题。
  • 我找到了原因。 IIS 6.0 定义了线程限制 (50)。解决此问题的方法是使用自定义主机托管我的服务。

标签: wcf wcf-client performance


【解决方案1】:

您可能达到了外出 http 连接的连接限制:

<system.net>
  <connectionManagement>
     <add address="*" maxconnection="8"/>
  </connectionManagement>
</system.net> 

注意默认值为 2。

【讨论】:

  • 和ServicePointManager.DefaultConnectionLimit一样吗?我已在代码中将其更新为 1000。
  • 我不认为它是一样的。尝试将上述配置放入您的 wcf 客户端的配置文件中。
  • 将 ServicePointManager.DefaultConnectionLimit 设置为 8(无论如何在我的 .NET 4 应用程序中),所以它们看起来是一样的。
猜你喜欢
  • 1970-01-01
  • 2012-03-28
  • 1970-01-01
  • 2013-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-10
  • 1970-01-01
相关资源
最近更新 更多