This topic has not yet been rated - Rate this topic

ServiceThrottle Class

Controls the throughput of a service to optimize availability and performance.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public final class ServiceThrottle

Use the ServiceThrottle to tune the performance characteristics of a service. The easiest way to configure the ServiceThrottle for a service is to use the ServiceThrottlingBehavior, especially from an application configuration file.

The MaxConcurrentCalls property specifies the maximum number of messages actively processing across all the dispatcher objects in a ServiceHost object.

The MaxConcurrentInstances property specifies the maximum number of InstanceContext objects in the service.

The MaxConcurrentSessions property specifies the maximum number of sessions a ServiceHost can accept.

NoteNote:

A trace is written when the first call, InstanceContext, or session is queued on the waitlist. The first trace is written as a warning.

The following code example shows the typical use of the ServiceThrottle by referencing the ServiceThrottlingBehavior in an application configuration file. In this case, the values that are specified establish, at most, one message processing at one time from one connection to one InstanceContext. Real-world usage must be determined through experience.

<configuration>
  <appSettings>
    <!-- use appSetting to configure base address provided by host -->
    <add key="baseAddress" value="http://localhost:8080/ServiceMetadata" />
  </appSettings>
  <system.serviceModel>
    <services>
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="Throttled" >
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService"/>
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
         />
        <endpoint
          address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange"
         />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior  name="Throttled">
          <serviceThrottling 
            maxConcurrentCalls="1" 
            maxConcurrentSessions="1" 
            maxConcurrentInstances="1"
          />
          <serviceMetadata 
            httpGetEnabled="true" 
            httpGetUrl=""
          />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
System.Object
  System.ServiceModel.Dispatcher.ServiceThrottle
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.