我想知道使用可靠 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 上,这些是默认值:
maxConcurrentCalls 默认值为 16 * 处理器数量。将其设置为 0 会将值设置为 Int32.MaxValue
.
maxConcurrentInstances 默认值为 maxConcurrentCalls
的总和和maxConcurrentSessions
.
maxConcurrentSessions 默认值为 100 * 处理器数量。将其设置为 0 会将值设置为 Int32.MaxValue
.
因此,就您的情况而言,如果您有 4 个处理器,您的服务将支持 64 个并发调用、400 个并发 session 和 464 个并发实例。
根据我使用 WCF 的经验,即使您没有专门包含空标记,也会使用默认值。例如,<security>
可以从绑定(bind)中省略标记,并且无论如何都会使用安全性的默认值。
关于wcf - WCF 限制是否默认开启?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33919105/