分析为什么WCF比WSE webservice慢得多

Yur*_*luk 8 c# performance wcf wse web-services

我们有一个Web服务,包含WSE 3.0端点和.NET Framework 4.5上的新WCF端点.

WCF正在使用basicHttpBinding.

问题是新的WCF绑定似乎明显更慢(~3x).引擎盖下是否使用相同的机制?

我已经阅读了很多关于启用WCF跟踪的内容.但是当我在生产中启用它时,我得到了很多信息并且不知道如何阅读,例如Microsoft Trace Viewer中的时间线.

我将不胜感激任何帮助

  • 找到性能差异原因的提示
  • 从理论角度来看的想法,例如,WCF处理请求的方式有什么重大差异吗?
  • 任何可以帮助配置WCF服务器的工具

笔记:

  • 生产中存在问题; 在测试服务器上一切都很顺利.起初我们怀疑负载均衡器可能是一个因素,但是禁用负载均衡器根本不会改变性能

  • 缓慢可能是由于我们的应用程序/域层.也许某些线程/连接池正在阻塞,并且消息因此而排队.

    在这种情况下,是否有人知道为什么行为与WSE(在同一个应用程序池上运行)如此不同?WSE3.0和WCF之间的队列大小/并发处理默认配置是否发生了显着变化?

    有没有办法找出这种情况何时发生?比如perfmon要看一些柜台?在perfmon我刚刚迷路可用的性能计数器的巨额之间进行选择

更新

这是我们的服务Web.config的匿名版本:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    </configSections>
    <system.web>
        <httpRuntime executionTimeout="900" maxRequestLength="10240" />
        <webServices>
            <!--<wsdlHelpGenerator href="CustomizedWebServicePage.aspx" />-->
            <protocols>
                <add name="HttpGet" />
                <add name="HttpPost" />
            </protocols>
            <soapExtensionTypes>
                <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" />
            </soapExtensionTypes>
        </webServices>
        <compilation defaultLanguage="cs" debug="true" targetFramework="4.5" />
        <customErrors mode="RemoteOnly" />
        <!-- dev only - application pool identity is configured on real environment -->
        <identity impersonate="true" userName="ServiceIdentity" password="********" />
        <authentication mode="Windows" />
        <authorization>
            <allow users="*" />
            <!-- Allow all users -->
        </authorization>
        <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
        <sessionState mode="InProc" cookieless="false" timeout="20" sqlConnectionString="data source=127.0.0.1;user id=someuserid;password=********;port=42424" />
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
    </system.web>
    <microsoft.web.services2>
        <diagnostics>
            <detailedErrors enabled="true" />
        </diagnostics>
        <policy>
            <cache name="policyCache.xml" />
        </policy>
        <security>
            <timeToleranceInSeconds>43200</timeToleranceInSeconds>
            <defaultTtlInSeconds>43200</defaultTtlInSeconds>
            <x509 storeLocation="LocalMachine" verifyTrust="false" />
            <securityTokenManager type="OurProduct.Business.Authentication.CustomUsernameTokenManager, OurProduct.Business, Version=5.0.2.11517, Culture=neutral" qname="wsse:UsernameToken" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />
        </security>
        <messaging>
            <maxRequestLength>10240</maxRequestLength>
        </messaging>
    </microsoft.web.services2>
    <startup>
        <supportedRuntime version="v2.0.50727" />
    </startup>
    <system.serviceModel>
        <diagnostics wmiProviderEnabled="true">
            <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <services>
            <service behaviorConfiguration="OurServiceBehavior" name="OurProduct.Service.OurService">
                <endpoint address=""      binding="basicHttpBinding"  bindingConfiguration="BasicHttpBinding_IXXXOurService" bindingNamespace="http://localhost/XXXOurService" contract="OurProduct.ServiceContracts.XXXOurService.IXXXOurService" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="OurServiceBehavior">
                    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
                    <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <serviceCredentials>
                        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="OurProduct.Service.Validation.CustomUserNamePasswordValidator, OurProduct.Service" />
                    </serviceCredentials>
                </behavior>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IXXXOurService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288000" maxBufferSize="524288000" transferMode="Buffered" maxReceivedMessageSize="524288000" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                    <readerQuotas maxDepth="524288000" maxStringContentLength="524288000" maxArrayLength="524288000" maxBytesPerRead="524288000" maxNameTableCharCount="524288000" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="None"     />
                        <message   clientCredentialType="UserName" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
    </system.serviceModel>
    <runtime>
        <gcServer     enabled="true" />
        <gcConcurrent enabled="true" />
    </runtime>
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="10485761" /> <!-- 10 megabytes -->
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

小智 0

抱歉回答,我没有足够的评论声誉。您希望看到哪些具体信息(痕迹)?如果您在设置跟踪时遇到困难,我建议您使用名为 SvcConfigEditor.exe 的工具。在其中,您可以打开 WCF 服务的 App.Config 文件,并在“诊断”下启用跟踪。之后,您可以选择是否要跟踪特定信息 - 所谓的“跟踪级别”(有关特定级别的更多信息 -配置跟踪)。请参阅该工具的屏幕截图: 配置

跟踪所需信息后,您可以在 Microsoft Trace Viewer 中打开日志 - 在其中,您可以查看每个活动的持续时间: 例如考虑这个(抱歉 - 有些标签是捷克语):

抱歉,图片无法读取,这里是更大图片的链接:Traceviewer

在左侧,您可以选择特定活动 - 如果拉伸面板,您甚至可以看到开始和结束时间。此外,您还可以看到该活动的总持续时间。选择它后,在左上角面板中,您可以看到属于该活动的所有呼叫,您还可以看到哪个呼叫花费最多时间来解决(在“时间”列中)。