次の方法で共有


WCF Web Service パフォーマンスの最適化

WCF サービスは、パフォーマンスに影響を与える多数の構成パラメーターを公開します。 このトピックでは、WCF サービスのパフォーマンスを向上させるために、これらの構成パラメーターに最適な値を設定するための一般的なガイダンスを提供します。

バックエンド WCF サービスの serviceThrottling 動作を実装する

バックエンド WCF サービスの serviceThrottling 動作を実装します。 サービス調整を使用すると、バックエンド WCF サーバーの負荷を均等に引き出し、リソース割り当てを適用できます。 バックエンド WCF サービスの serviceThrottling 動作は、WCF サービスの構成ファイル内の maxConcurrentCallsmaxConcurrentSessionsおよび maxConcurrentInstances パラメーターの値を変更することによって構成されます。 maxConcurrentCallsmaxConcurrentSessionsmaxConcurrentInstances を 16 より大きい値 * CPU または CPU コアの数に設定します。 たとえば、CPU コアが 8 個のコンピューターで、次のように maxConcurrentCallsmaxConcurrentSessionsmaxConcurrentInstances を 128 (16 * 8 = 128) より大きい値に設定します。

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

バックエンド WCF サービス web.config ファイルの NetTcpBinding.ListenBacklog プロパティと NetTcpBinding.MaxConnections プロパティの既定値を増やす

NetTcpBinding.ListenBacklog プロパティは、Web サービスに対して保留中のキュー接続要求の最大数を制御します。 NetTcpBinding.MaxConnections プロパティは、クライアントで後続の再利用のためにプールする接続の最大数と、サーバーでのディスパッチを保留にできる接続の最大数を制御します。 これらの各プロパティでは、特に高スループットを必要とするドキュメント処理シナリオでは、最適ではない可能性がある既定値 10 が使用されます。

netTcpBinding バインド クラスを実装する WCF サービスを使用する高スループットのドキュメント処理シナリオでは、これらのプロパティの既定値を増やすことを検討してください。

次の例では、 listenBacklog パラメーターと maxConnections パラメーターの両方が値 "200" に設定されています。

<netTcpBinding>
   <binding name="netTcpBinding"
      closeTimeout="00:10:00"
      openTimeout="00:10:00"
      receiveTimeout="00:10:00"
      sendTimeout="00:10:00"
      transactionFlow="false"
      transferMode="Buffered"
      transactionProtocol="OleTransactions"
      hostNameComparisonMode="StrongWildcard"
      listenBacklog="200"
      maxBufferPoolSize="1048576"
      maxBufferSize="10485760"
      maxConnections="200"
      maxReceivedMessageSize="10485760">
      <readerQuotas
         maxDepth="32"
         maxStringContentLength="8192"
         maxArrayLength="16384"
         maxBytesPerRead="4096"
         maxNameTableCharCount="16384" />
      <reliableSession
         ordered="true"
         inactivityTimeout="00:10:00"
         enabled="false" />
      <security mode="None">
         <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
         <message clientCredentialType="Windows" />
      </security>
   </binding>
</netTcpBinding>

NetTcpBinding.ListenBacklog プロパティの詳細については、「 NetTcpBinding.ListenBacklog プロパティ」を参照してください。

NetTcpBinding.MaxConnections プロパティの詳細については、「 NetTcpBinding.MaxConnections プロパティ」を参照してください。

WCF Web サービス ASP.NET 実行する必要のない httpModule を排除する

既定では、IIS 6.0 の要求パイプラインと IIS 7.5/7.0 のクラシック パイプラインまたは統合パイプラインで、いくつかの ASP.NET httpModule が定義されています。 これらのコンポーネントは、すべての受信要求をインターセプトして処理します。 既定のモジュールは、次のスニペットに示すように、32 ビット ASP.NET アプリケーションの %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG フォルダーと、64 ビット ASP.NET アプリケーションの %windir%\Microsoft.NET\Framework64\v2.0.50727\CONFIG フォルダーに含まれる web.config ファイルで定義されます。

<httpModules>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/>
<add name="RoleManager" type="System.Web.Security.RoleManagerModule"/>
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/>
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/>
<add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/>
<add name="Profile" type="System.Web.Profile.ProfileModule"/>
<add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</httpModules>

ほとんどのシナリオでは、これらのモジュールをすべて読み込む必要はありません。 したがって、WCF Web サービスの実行時に次の httpModule を排除することで、パフォーマンスを向上させることができます。

  • Session

  • WindowsAuthentication

  • FormsAuthentication

  • PassportAuthentication

  • RoleManager

  • AnonymousIdentification

  • プロファイル

非同期 WCF HTTP モジュール/ハンドラーを使用して IIS 7.5/7.0 でホストされる WCF サービスのスケーラビリティを向上させる方法の詳細については、Wenlong Dong のブログ 「Orcas SP1 Improvement: Async WCF HTTP Module/Handler for IIS7 for Better Server Scalability」を参照してください。

参照

BizTalk Server WCF Adapter パフォーマンスの最適化