Επεξεργασία

Κοινή χρήση μέσω


<serviceThrottling>

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

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <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 * processor count.
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 the sum of maxConcurrentSessions and MaxConcurrentCalls
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). The default is 100 * processor count.

Child Elements

None.

Parent Elements

Element Description
<behavior> 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