<转>WCF实例化模式与高并发处理

WCF实例化模式与高并发控制

1.实例化模式InstanceModel

1.1 PerCall:单调模式

    每次调用都会产生一个实例

    例[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]

 

1.2 PerSession会话模式   

    每次调用都有同一个服务进行处理

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]

 

1.3 SingleTon 单例模式    

    多个请求,只有一个实例

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

 

 

2.并发控制

在服务行为里设置

<serviceThrottling

   maxConcurrentCalls="1000"         //最大并发请求消息数量

   maxConcurrentInstances="1000"     //最大并发服务实例的数量

   maxConcurrentSessions="1000" />   //最大并发会话连接数

 

 

<behaviors>

  <serviceBehaviors>

      <behavior name="WCFService.WCFServiceBehavior">

         <serviceMetadata httpGetEnabled="false"/>

         <serviceDebug includeEXceptionDetilInfaults="false"/>

         <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessins="100" maxConcurrentInstances="1000"/>

      </behavior>

  </serviceBehaviors>

</behaviors>
View Code

 

你可能感兴趣的:(WCF)