【问题标题】:WCF slow on every requestWCF 对每个请求都很慢
【发布时间】:2012-12-07 18:54:36
【问题描述】:

我有一个 WCF 服务,它与 SQL 服务器连接并获取一些数据、构造对象然后返回它。我使用简单的绑定,.NET 4.0,当您创建 WCF 服务时,我没有添加任何特殊设置,只是模板中的默认设置。

该服务在我的本地数据库上运行良好,但是现在当我部署在服务器上时,我检查了时间,处理需要 7 微秒(第一个需要多一点),但在到达开始处理之前,WCF 需要 3 秒 在点击第一行代码之前的每个请求,我找不到原因。

<endpoint address="http://localhost/Service.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService" contract="Local.IService"
            name="BasicHttpBinding_IService" />

谢谢!

服务行为:

    <behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

绑定:

    <bindings>
<basicHttpBinding>
        <binding name="BasicBinding" maxReceivedMessageSize="10485760" />
</basicHttpBinding>
</bindings>

【问题讨论】:

  • 您的“ServiceBehavior”属性是什么样的?请张贴。
  • 对不起,我指的是类上的 ServiceBehavior 属性。
  • 我在类上没有任何 ServiceBehavior 属性
  • 您如何托管您的 WCF 服务,它是自托管还是在 IIS 上?另外,您是否分析了您的数据库查找代码?

标签: wcf wcf-binding wcf-client


【解决方案1】:

在请求到达 IIS 和到达 C# 代码之间发生的主要事情之一是安全检查。根据您的设置,您的开发机器上可能没有任何安全性。

假设您正在使用带有 NTLM 的 Windows 身份验证。然后有一个 3 请求握手与 http 、 401.2、 401.1 和 200 响应。在这些请求之间,您的 Web 服务器将与您的 AD 服务器进行通信。

您应该能够通过检查 IIS 日志来确定这是否是问题所在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-24
    • 1970-01-01
    • 2011-03-23
    • 1970-01-01
    • 2018-06-28
    • 2019-09-03
    • 1970-01-01
    • 2014-07-08
    相关资源
    最近更新 更多