ServiceThrottlingBehavior 類別

定義

設定可讓您調整服務效能的執行階段輸送量設定。

public ref class ServiceThrottlingBehavior : System::ServiceModel::Description::IServiceBehavior
public class ServiceThrottlingBehavior : System.ServiceModel.Description.IServiceBehavior
type ServiceThrottlingBehavior = class
    interface IServiceBehavior
Public Class ServiceThrottlingBehavior
Implements IServiceBehavior
繼承
ServiceThrottlingBehavior
實作

範例

下列程式碼範例會示範如何使用應用程式組態檔的 ServiceThrottlingBehavior,將 MaxConcurrentSessionsMaxConcurrentCallsMaxConcurrentInstances 屬性設定為 1。 至於特定應用程式的最佳設定,則需要透過實際經驗來判斷。

<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>

備註

您可以使用 ServiceThrottlingBehavior 類別來控制可協助您的應用程式避免用完記憶體的各種輸送量設定。

MaxConcurrentCalls 屬性會限制目前在 ServiceHost 上處理的訊息數目。

MaxConcurrentInstances 屬性會限制 InstanceContext 上執行一次的 ServiceHost 物件數目。

MaxConcurrentSessions 屬性會限制 ServiceHost 物件可以接受的工作階段數目。

由於執行階段負載平衡需要執行應用程式的經驗,因此透過應用程式組態檔使用 ServiceThrottlingBehavior 是最常見的修改執行,使服務效能最佳化的方法。

注意

每次達到這些屬性值時,就會寫入追蹤。 第一個追蹤會寫入成為警告。

您也可以在應用程式組態檔中使用< serviceThrottling >元素來設定此屬性的值。

建構函式

ServiceThrottlingBehavior()

初始化 ServiceThrottlingBehavior 類別的新執行個體。

屬性

MaxConcurrentCalls

取得或設定值,這個值指定 ServiceHost 上主動處理的訊息數目上限。

MaxConcurrentInstances

取得或設定值,這個值指定服務中一次可以執行的 InstanceContext 物件數目上限。

MaxConcurrentSessions

取得或設定值,指定 ServiceHost 物件一次可以接受的工作階段數目上限。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IServiceBehavior.AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection)

設定繫結以支援服務行為。

IServiceBehavior.ApplyDispatchBehavior(ServiceDescription, ServiceHostBase)

設定服務以支援服務行為。

IServiceBehavior.Validate(ServiceDescription, ServiceHostBase)

確認服務和主機可以支援服務行為。

適用於