ServiceThrottle 類別

定義

控制服務輸送量,以便最佳化可用性和效能。

public ref class ServiceThrottle sealed
public sealed class ServiceThrottle
type ServiceThrottle = class
Public NotInheritable Class ServiceThrottle
繼承
ServiceThrottle

範例

下列程式碼範例將示範參考應用程式組態檔內 ServiceThrottle 的典型 ServiceThrottlingBehavior 用法。 在此情況下,所指定的值一次最多會建立一個訊息處理 (從一個連線到一個 InstanceContext)。 實際用法必須取決於經驗。

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

備註

使用 ServiceThrottle,即可調整服務的效能特性。 為服務設定 ServiceThrottle 的最簡易方式是使用 ServiceThrottlingBehavior,尤其是從應用程式組態檔中進行設定。

MaxConcurrentCalls 屬性會指定在 ServiceHost 物件中所有發送器物件上主動處理訊息的數目上限。

MaxConcurrentInstances 屬性會指定服務中 InstanceContext 物件的數目上限。

MaxConcurrentSessions 屬性會指定 ServiceHost 可以接受的工作階段數目上限。

注意

當第一個呼叫、InstanceContext 或工作階段佇列排入等候清單 (Waitlist) 時,就會寫入追蹤。 第一個追蹤會寫入成為警告。

屬性

MaxConcurrentCalls

取得或設定在 ServiceHost 中的所有發送器物件上主動處理訊息的數目上限。

MaxConcurrentInstances

取得或設定可以同時執行服務物件的數目上限。

MaxConcurrentSessions

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

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於