Performance WCF服务超时-服务响应简单请求需要几分钟

Performance WCF服务超时-服务响应简单请求需要几分钟,performance,wcf,wcf-binding,Performance,Wcf,Wcf Binding,我们有一个简单的服务配置,如下所示: <configuration> <connectionStrings> <add name="CONN" connectionString="Server=MYSERVER,1433;Database=mydb;User Id=user;Password=pass;"/> </connectionStrings> <system.web> <customErrors

我们有一个简单的服务配置,如下所示:

<configuration>
  <connectionStrings>
    <add name="CONN" connectionString="Server=MYSERVER,1433;Database=mydb;User Id=user;Password=pass;"/>
  </connectionStrings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MyNamespace.MyService">
        <host>
          <baseAddresses>
            <add baseAddress="https://mywebsite.com/TestService/"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="basicHttpBinding" contract="MyNameSpace.IMyService" bindingConfiguration="defaultBinding" bindingNamespace="MyNameSpace"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="defaultBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" 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>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

在我向binding name=“defaultBinding”(closeTimeout、openTimeout、receiveTimeout、sendTimeout、maxbuffersize、maxreceivedmessagesize)添加附加参数之前,服务超时

我们的服务器只启用了TLS1.2。 该服务托管在IIS中,证书似乎还可以-在web上浏览WSDL看起来还可以

在托管服务的同一台机器上使用SOAPUI超时(我想这会很快吗?)

是否存在我不知道的web配置设置,或者这是否取决于服务器计算机或IIS

请求可能需要几分钟才能完成——即使是像只返回字符串的GetVersion()调用这样的简单请求。我们甚至重新启动了机器、IIS等,并尝试了新的请求-同样的问题。

结果表明,我的GetVersion()调用实际上有一个LogActivity()调用,该调用将记录到数据库中。web.config中的连接字符串不正确,导致数据库连接旋转,直到数据库连接超时。数据库连接超时设置高于服务/客户端的超时,因此客户端将在数据库超时发生之前超时。数据库连接超时以静默方式发生,因为不需要为我们记录失败的日志记录尝试

修复连接字符串可以使服务快速响应


故事的寓意:仔细检查你的功能——即使它们看起来很简单——它们可能在幕后做一些其他事情:)

像往常一样处理所有WCF时间问题——启用WCF的详细日志并检查时间花在哪里:感谢你提供的资源@IgorLabutin我将研究如何做,并会带着我找到的任何东西回来。我调查了一下@IgorLabutin,并将我的答案发布在下面。服务请求消息所花费的时间导致连接超时。非常感谢。