【发布时间】: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