Compartilhar via


<serviceThrottling>

Specifies the throttling mechanism of a Windows Communication Foundation (WCF) service.

Schema Hierarchy

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior> of <serviceBehaviors>
        <serviceThrottling>

Syntax

<serviceThrottling maxConcurrentCalls="Integer"
    maxConcurrentInstances="Integer"
    maxConcurrentSessions="Integer" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

maxConcurrentCalls

A positive integer that limits the number of messages that currently process across a ServiceHost. Calls in excess of the limit are queued. Setting this value to 0 is equivalent to setting it to Int32.MaxValue. The default is 16.

maxConcurrentInstances

A positive integer that limits the number of InstanceContext objects that execute at one time across a ServiceHost. Requests to create additional instances are queued and complete when a slot below the limit becomes available. The default is Int32.MaxValue.

maxConcurrentSessions

A positive integer that limits the number of sessions a ServiceHost object can accept.

The service will accept connections in excess of the limit, but only the channels below the limit are active (messages are read from the channel). Setting this value to 0 is equivalent to setting it to Int32.MaxValue. The default is 10.

Child Elements

None.

Parent Elements

Element Description

<behavior> of <endpointBehaviors>

Specifies a behavior element.

Remarks

Throttling controls place limits on the number of concurrent calls, instances, or sessions to prevent over-consumption of resources.

A trace is written every time the value of attributes is reached. The first trace is written as a warning.

Example

The following configuration example specifies that the service limits the maximum concurrent calls to 2, and the maximum number of concurrent instances to 10. For a detailed example of running this example, see Throttling.

<behaviors> 
  <serviceBehaviors> 
    <behavior name="CalculatorServiceBehavior"> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- Specify throttling behavior -->
      <serviceThrottling maxConcurrentCalls="2" 
           maxConcurrentInstances="10"/> 
    </behavior>
  </serviceBehaviors>
</behaviors>

See Also

Reference

ServiceThrottlingBehavior
ServiceThrottlingElement

Other Resources

Using ServiceThrottlingBehavior to Control WCF Service Performance


© 2007 Microsoft Corporation. All rights reserved.
Last Published: 2010-01-05