zoukankan      html  css  js  c++  java
  • 研究WCF并发及处理能力的控制

    WCF 跟并发 性能相关的几个配置:
    1、系统控制的客户端网络连接并发(如果服务端也需要并发请求的话这个参数也是需要的):
             <configuration>                <system.net>                        <connectionManagement>                                   <add address="*" maxconnection="1000"/>                          </connectionManagement>                </system.net>         <configuration>         这个参数指定一个进程内(或domain) 并发通信连接个数限制,默认2个(就是系统控制了)
    2、WCF 网络TCP/IP 监听(bingding)控制的传输协议      这个参数是针对某一(些)端点的绑定的控制
                 <bindings>

                    <netTcpBinding>

                            <bindingname="netcpbindingconfig"                 

                                          listenBacklog="100"      maxConnections="100" />

            这2个参数: 第一个就是我们常用的listen的参数,这个意义我们应该很清楚了。

                               第二个参数 msdn解释是: 客户端上可存入池中以备后续重复使用的最大连接数;服务器上可挂起调度的最大连接数。  On the client, the maximum number of connections to be  pooled for subsequent reuse; on the server, the maximum number of  connections allowed to be pending dispatch. (看来中文翻译的不太好)。

                              第一个是tcp协议的控制,第二个是紧跟着协议之后的调度配置(服务端)。

     

          3、针对服务宿主(servicehost)进行的控制

            <serviceBehaviors>

    <behaviorname="MathServiceBehaviours" >

    <serviceThrottling

     

    maxConcurrentCalls="100"

     

    maxConcurrentSessions="100"

     

    maxConcurrentInstances="100"/>

     

    </behavior>

    </serviceBehaviors>

     

         maxConcurrentCalls :该值指定整个 ServiceHost中正在处理的最多消息数。

              specifies the maximum number of messages actively processing across a ServiceHost.

                     

    总结,在服务端控制流量的机制即listenBackLog -> maxConnections -> maxConcurrentCalls(..)

                基本上分三个阶段。也是针对不同的可控制对象。

                listenBackLog 针对tcp连接的缓冲设置

                maxConnections 针对接到连接后,要分配给service消费是 排队(缓冲)的设置;

                maxConcurrentCalls(sessions, instances) 是针对service处理压力的控制。

     

    比较完美了!

  • 相关阅读:
    批量新增百万条数据 十百万条数据
    sqlserver 组内排序
    EF ++属性会更新实体
    Entity Framework Core: A second operation started on this context before a previous operation completed
    abp Cannot access a disposed object. A common cause of this error is disposing
    abp xunit Can not register IHostingEnvironment. It should be a non-abstract class. If not, it should be registered before.”
    hangfire enqueued but not processing(hangfire 定时任务入队列但不执行)
    EF 更新实体 The instance of entity type 'BabyEvent' cannot be tracked because another instance
    datatable to entiy list 不支持可空类型和枚举类型
    webapi 设置不显示接口到swaggerUI
  • 原文地址:https://www.cnblogs.com/gjhjoy/p/3487364.html
Copyright © 2011-2022 走看看