wcf - WCF 限制是否默认开启?

标签 wcf default throttling

我想知道使用可靠 session 时是否会自动应用服务限制。我在网上搜索和 msdn 时找不到明确的答案。

我倾向于认为你必须输入 <serviceThrottling /><serviceBehavior />元素以启用它。

问题是,不同的博客如 this one让我失望的是你应该注意默认的限制值。

这是我的一般问题,但我也想知道我的特殊情况的答案。我的配置当前具有以下行为:

 <behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

如您所见,我不包括 <serviceThrottling />元素。是否仍然启用了限制,或者我是否使用此配置成功阻止了限制?

编辑:

我刚刚在OperationContext.Current.Channel.ChannelDispatcher.Endpoints.owner.ServiceThrottle中检查了服务器上的运行时并且它的值为空。这让我更倾向于禁用 ServiceThrotdling 的想法。

但是,我不太确定这是否是正确的检查路径,也不确定这是否并不意味着因为它为空,所以某些默认内容将在 WCF 核心的某处被使用。

最佳答案

根据 <serviceThrottling> 在 MSDN 上,这些是默认值:

ma​​xConcurrentCalls 默认值为 16 * 处理器数量。将其设置为 0 会将值设置为 Int32.MaxValue .

ma​​xConcurrentInstances 默认值为 maxConcurrentCalls 的总和和maxConcurrentSessions .

ma​​xConcurrentSessions 默认值为 100 * 处理器数量。将其设置为 0 会将值设置为 Int32.MaxValue .

因此,就您的情况而言,如果您有 4 个处理器,您的服务将支持 64 个并发调用、400 个并发 session 和 464 个并发实例。

根据我使用 WCF 的经验,即使您没有专门包含空标记,也会使用默认值。例如,<security>可以从绑定(bind)中省略标记,并且无论如何都会使用安全性的默认值。

关于wcf - WCF 限制是否默认开启?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33919105/

相关文章:

c# - "Fixed"/"Load Balanced"C# 线程池?

c# - 覆盖派生类中的默认值 (c#)

c++ - 在构造函数中设置默认参数?句法

c# - 如何使用 Reactive Extensions 使用最大窗口大小来限制事件?

algorithm - throttle 请求的速率限制算法

wcf - MSMQ WCF 限制

wcf - 内容类型 application/soap+xml;服务不支持 charset=utf-8

c# - 序列化用于 WCF 服务的 CLR 对象时出错

c# - .NET Remoting 被 WCF 取代了吗?

android - textview中文本的默认颜色是什么?