• 【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;
    }
     
  • 相关阅读:
    [HNOI 2015]菜肴制作
    [HNOI 2015]落忆枫音
    [NOIp 2009]靶形数独
    [HNOI 2010]Bounce 弹飞绵羊
    [CTSC 1999]拯救大兵瑞恩&[网络流24题]孤岛营救问题
    [SDOI 2008]Cave 洞穴勘测
    pandas 5 str 参考:https://mp.weixin.qq.com/s/Pwz9iwmQ_YQxUgWTVje9DQ
    比较工具
    当小内存遇上大量数据,你该怎么解决这个问题?
    python高性能编程 读书笔记
  • 原文地址:https://www.cnblogs.com/yanglang/p/7874823.html
Copyright © 2020-2023  润新知