WCF服务在本地计算机上快速运行,而在网络上运行缓慢 [英] WCF service fast in local machine, slow on the web

查看:93
本文介绍了WCF服务在本地计算机上快速运行,而在网络上运行缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我将服务交付给Web服务器上的IIS,我就面临着WCF的巨大性能问题.

Hi, I'm facing big WCF performance issues once I deply my service to IIS on my web server.

服务是在IIS(WS2012)中自托管的,并且是使用VS2012开发的.

Service is self-hosted in IIS (WS2012) and is developed with VS2012.

当我在本地测试该服务时,我会立即获取数据,但是当我调用Web上的IIS中托管的服务时,最多需要5秒钟才能获取相同的数据.

When I test the service locally I get data imediately, but when I call the service hosted in IIS on the web it takes up to 5 seconds to get the same data.

这是我的网络配置的一部分:

Here's a portion of my web config:

<services>
      <service name="G8Service.G8Service">
        <endpoint address="" binding="customBinding" contract="G8Service.IG8Service" bindingConfiguration="ReliableBindingConfig"></endpoint>
      </service>
    </services>
    <bindings>
      <customBinding>
        <binding name="binHttp">
            <binaryMessageEncoding compressionFormat="GZip" maxReadPoolSize="100000000" maxSessionSize="100000000" maxWritePoolSize="100000000"></binaryMessageEncoding>
            <httpTransport keepAliveEnabled="true" transferMode="Buffered" maxBufferSize="100000000" maxReceivedMessageSize="100000000" maxBufferPoolSize="100000000" />
        </binding>
      <binding name="ReliableBindingConfig" closeTimeout="00:20:00" receiveTimeout="00:40:00" openTimeout="00:20:00" sendTimeout="00:40:00">
      <transactionFlow />
      <reliableSession maxRetryCount="12" ordered="true" inactivityTimeout="00:40:00" />
      <mtomMessageEncoding maxBufferSize="2147483647" maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
        <readerQuotas maxDepth="32" maxBytesPerRead="4096" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxNameTableCharCount="16384" />
      </mtomMessageEncoding>
      <httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
    </binding>
      </customBinding>
      <wsHttpBinding>
        <binding name="G8Binding" maxReceivedMessageSize="100000000" maxBufferPoolSize="10000000" closeTimeout="00:10:00"></binding>
      </wsHttpBinding>
    </bindings>

我认为响应速度慢与绑定类型有关,我尝试了标准baseHttpBinding和标准wsHttpBinding,结果相同.我从论坛上了解到netTcpBinding对于网络上的服务不适合,任何提示都值得赞赏,我完全同意 卡住了.

I believe the slow response is related to the binding type, I tried standard baseHttpBinding as well as standard wsHttpBinding with same result. I read from forums that netTcpBinding is not ok for services on the web, any hint is appreciated, I'm completely stuck..

推荐答案

为了查看延迟是否来自服务器端处理本身,您可以启用WCF跟踪,以查看哪个活动需要很长时间才能处理.

In order to see if the delay is coming from server side processing itself, you can enable WCF Tracing, to see which activity is taking a long time for processing.

请参考以下文章以启用WCF跟踪:
配置跟踪
http://msdn.microsoft.com/en-us/library/ms733025.aspx

Please refer to the following article to enable WCF Tracing :
Configuring Tracing
http://msdn.microsoft.com/en-us/library/ms733025.aspx

要验证延迟是否来自System.Net层,可以配置System.Net跟踪,这将有助于确定System.Net层中的调用是否正在消耗更多时间.

To verify if the delay is coming from the System.Net layer, you could configure System.Net tracing, this will help determine if calls in the System.Net layer are consuming more time.

如何:配置网络跟踪
http://msdn.microsoft.com/en-us/library/ty48b824.aspx

How to: Configure Network Tracing
http://msdn.microsoft.com/en-us/library/ty48b824.aspx

另外,请检查 中的最大连接值<连接管理> System.Net设置中的元素
<连接管理>元素(网络设置)
http://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx   ;

Also, please check the maxconnection value in  <connectionManagement> element in System.Net settings
<connectionManagement> Element (Network Settings)
http://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx 

如果这些输出都没有帮助-您可能需要联系技术支持以寻求帮助,因为性能下降可能有多种原因.

If none of these outputs help - you may need to contact tech support for assistance, as there could be multiple reasons for slow performance.


这篇关于WCF服务在本地计算机上快速运行,而在网络上运行缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆