Windows 7上的WCF性能

时间:2009-11-11 23:20:06

标签: windows-7 performance

我在Windows 7环境中对WCF有一个有趣的问题......它是slooooooow。

该服务是自托管的,在控制台应用程序中运行。

在Vista环境中运行的相同代码大约运行1/3。

服务器配置:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="Logging.Services.LoggerServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceThrottling maxConcurrentCalls="10000" maxConcurrentSessions="1000" maxConcurrentInstances="1000" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <netTcpBinding>
            <binding name="nettcp" maxBufferSize="524288" maxConnections="1000" maxReceivedMessageSize="524288">
                <security mode="None">
                    <transport clientCredentialType="None" protectionLevel="None" />
                    <message clientCredentialType="None" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="Logging.Services.LoggerServiceBehavior" name="Logging.Services.LoggerService">
            <endpoint address="" binding="netTcpBinding" bindingConfiguration="nettcp"
             name="tcp" contract="Logging.Services.Contracts.ILogger" />
            <host>
                <baseAddresses>
                    <add baseAddress="net.tcp://localhost:8001/LoggerService" />
                    <add baseAddress="http://localhost:8002/LoggerService" />
                </baseAddresses>
            </host>
        </service>
    </services>
</system.serviceModel>

客户端配置:

        <netTcpBinding>
            <binding name="tcp" closeTimeout="00:01:00" openTimeout="00:01:00"
             receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
             transferMode="Buffered" transactionProtocol="OleTransactions"
             hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
             maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="524288">
                <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="16384"
                 maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                 enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>                 
            </binding>              
        </netTcpBinding>

        <endpoint address="net.tcp://localhost:8001/LoggerService" binding="netTcpBinding"
         bindingConfiguration="tcp" contract="LoggerLogService.ILogger"
         name="tcp" />

我在某处看到有类似问题的人,运行NOD32时必须关闭HTTP Check,我已经这样做了没有效果。我没有运气就完全禁用了NOD。

有什么想法吗?

提前致谢!

4 个答案:

答案 0 :(得分:1)

查看WCF Performance Counters以找出瓶颈可能发生的位置。

答案 1 :(得分:0)

this post尝试将以下条目添加到绑定配置中:

useDefaultWebProxy = “假”

修改 由于您使用的是netTCP,请尝试增加maxConnections和maxmessagesize

答案 2 :(得分:0)

服务上设置的并发模式是什么?我不知道如何通过配置文件执行此操作,但在我的一个WCF服务上,我将此ServiceBehaviorAttribute添加到我的服务类:

[ServiceBehavior(
    Namespace="http://blah.com/",
    InstanceContextMode = InstanceContextMode.Single, 
    ConcurrencyMode=ConcurrencyMode.Multiple)]
public class MyService : IMyServiceInterface
{
    // ...
}

如果您的服务已经运行并发且事情仍然很慢,则可能是由于服务代码本身存在某些问题。虽然Vista的速度提高了3倍,但仍然听起来非常慢,具体取决于服务的功能。

答案 3 :(得分:0)

Meh ......道歉的人,我正在将我的存储库指向我工作的SQL服务器......如果我注意到整个时间内可用的7MB错误日志会有所帮助。我认为睡眠剥夺终于开始了。

非常感谢!