zoukankan      html  css  js  c++  java
  • 【WCF】WCF 附录 高级主题 配置服务配额设置

    微软产品自带一个“默认安全”方案。这也包括了WCF,意味着WCF中的多种配置可以设置来阻止诸如DOS(拒绝服务访问)攻击。微软为很多基于一个单一计算机的开发环境选择这样的设置。这也意味着默认设置中的一部分可能需要在生产环境中更改后才能使用。

      需要更改的默认设置之一是那些由ServiceThrottlingBehavior行为设置的配置。这个行为通过在服务端设置配额限制来限制资源使用数量。这个行为有三个设置: MaxConcurrentCalls, MaxConcurrentInstance 和 MaxConcurrentSessions. 表A.1 列出了ServiceThrottlingBehavior行为属性以及它们的默认值。

    设置 描述 默认值
    MaxConcurrentCalls 限制将要处理的同时调用总数。 16
    MaxConcurrentSessions 限制连接到一个服务的并发会话最大数量。 10
    MaxConcurrentInstances 限制一个服务并发实例的最大数量。 Int32.MaxValue

      MaxConcurrentCalls 和 MaxConcurrentSessions 都有可以在一个生产环境中潜在地限制吞吐量的默认值。如果你的服务需要接受更多吞吐而且你的服务有额外的资源去处理额外的负载的话那么你可以改这些设置。仅需要注意这些设置潜在的影响是可能导致拒绝服务访问攻击。列表A.4 显示了如何通过配置文件改这些设置。

    列表A.4 在配置文件中改ServiceThrottling

    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior name="ServiceThrottlingBehavior">
            <serviceThrottling maxConcurrentCalls="1000"
                                       maxConcurrentSessions="1000"
                                       maxConcurrentInstances="1000" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>

      列表A.5 显示了如何使用代码来更改这些设置。

    列表4.5 使用代码改ServiceThrottling

    public void IncreaseThrottle(ServiceHost serviceHost)
    {
        ServiceThrottlingBehavior throttleBehavior =
            serviceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
        if (throttleBehavior == null)
        {
            throttleBehavior = new ServiceThrottlingBehavior();
            serviceHost.Description.Behaviors.Add(throttleBehavior);
        }
        throttleBehavior.MaxConcurrentCalls = 4000;
        throttleBehavior.MaxConcurrentInstances = 4000;
        throttleBehavior.MaxConcurrentSessions = 4000;
    }
     
  • 相关阅读:
    Rx 键值观察KVO的使用
    js总结(6.1)获取DOM的各个属性 补充部分
    js总结(8)轮播小总结
    js总结 (7)事件
    js总结 (书本)《JavaScript DOM编程艺术 第2版》笔记
    js总结 (6) DOM操作 节点元素 遍历树
    css 补充之 checked应用 制作选中效果,以及z-index和position-fixed transfrom 之间层级关系
    js总结 (4)JavaScript高级程序设计
    js总结 (5)原型 原型链,,,继承的问题
    Css权威指南总结
  • 原文地址:https://www.cnblogs.com/yanglang/p/7874823.html
Copyright © 2011-2022 走看看