为什么WCF服务在传输大量文本数据时停止并发(大约20 MB)

时间:2015-11-09 05:26:14

标签: c# .net web-services wcf

我们有一个传输大量数据的WCF服务。突然之间我们的服务过去只用了大约一秒就开始花大约20分钟来执行。当我们进行一些调查时,我们发现服务调用是在客户端发送大约20分钟后在服务器上执行的。我们已将我们的服务配置为最多可同时进行500次呼叫。以下是我们的配置文件设置。

 <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    <behavior name="TransferServiceBehavior" >
      <serviceMetadata httpGetEnabled="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
    </behavior>
  </serviceBehaviors>

然后我们减少了服务传输的数据量,并且它的并发性恢复了。所以我们的问题是当我们传输大约20 MB的大量数据时,我们的服务停止并发。

1 个答案:

答案 0 :(得分:0)

服务限制的默认设置如下所示,基于处理器计数。

MaxConcurrentSessions:默认值为100 * ProcessorCount MaxConcurrentCalls:默认值为16 * ProcessorCount MaxConcurrentInstances:默认值是以上两者的总和,它遵循与之前相同的模式

http://blogs.msdn.com/b/wenlong/archive/2009/07/26/wcf-4-higher-default-throttling-settings-for-wcf-services.aspx

当您尝试传递大量数据时,您还可以尝试使用WSHttpBinding实现MTOM消息传输优化机制(MTOM)消息编码。