単一の IIS7 アプリケーション サーバーでホストされている WCF wsHttp サービスを呼び出す 2 つのサーバー間で負荷分散された Web サイトがあります。
先週、ウェブサイトが立ち上げられ、パフォーマンスの問題が発生しました。
このシステムはオフショア チームによって構築されましたが、調査を依頼されました。
perfmon をロードし、asp.net カウンターを使用して現在のセッションを表示しました。これが約 25 を超えると、Web サイトの速度が大幅に低下することがわかりました。次の 10 分間で約 250 まで増加し続け、その後 0 まで低下し、サイトのパフォーマンスは素晴らしいものになります。
これはサイクルで続きました - 悪いニュースです!
翌日、オフショア チームから、セキュリティを無効にすることで問題を解決したと連絡がありました。
wsHttpバインディングのセキュリティを無効にすると、WCFがセッションごとのインスタンスの作成から呼び出しごとのインスタンスの作成に変更されたという理論があります。したがって、サービス要求のスループットがはるかに高くなります。これは良い理論ですか?
これをテストするための単純なモデル、IIS でホストされるいくつかのメソッド、および複数の要求を生成する単純なクライアントを作成しました。これは私が期待した結果を与えるようです。問題は、安全なバインディングが使用されていない場合に、キューに入れられるリクエストが少なくなり、同時に作成されるインスタンスが増えることを証明する正しい perfmon カウンターを見つけるのに苦労していることです。
使用するのに最適な perfmon カウンターについてアドバイスをいただけますか?
OK、これについてはまた別の日に、さらに質問があります!
私のテスト アプリには、3 つの異なる wsHttp バインディングを持つ 3 つのサービス クラスがあります。
- セキュリティなし
- メッセージ セキュリティ
- クラスに [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] が設定されているメッセージ セキュリティ
クライアントで 40 のループ内から、新しいスレッドを開始し、サービスを呼び出します。サービス 1 を呼び出すと、サービスはすべての要求を 1 秒以内に完了します。
サービス 2 を呼び出すと、サービスはすべての要求を 33 秒で完了します。
サービス 3 を呼び出すときは、サービスが 4 つの呼び出しのそれぞれに対して新しいサービス オブジェクトをインスタンス化することを期待しているため、サービス 1 とほぼ同じくらい高速であると予想されます。ただし、これを実行することはないようです (私はまだ意味のある perfmon カウンターを持っていません!)。完了までの合計時間も 33 秒です。
サービスからの構成は次のとおりです。
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\WCFTrace\InstancingDemo.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SecPerCallBehaviour">
<serviceThrottling maxConcurrentSessions="1000"
maxConcurrentCalls="30"
maxConcurrentInstances="30"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="BindingNoSec">
<security mode="None" />
</binding>
<binding name="BindingMessageSec">
<security mode="Message">
<message establishSecurityContext ="true"/>
</security>
</binding>
<binding name="BindingMessageSecPerCall" >
<security mode="Message">
<message establishSecurityContext ="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ServiceInstancingDemo.Service1">
<endpoint address="~/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="BindingNoSec"
name="NoSecurity" contract="ServiceInstancingDemo.IService1" />
</service>
<service name="ServiceInstancingDemo.Service2">
<endpoint address="~/Service2.svc"
binding="wsHttpBinding" bindingConfiguration="BindingMessageSec"
contract="ServiceInstancingDemo.IService2" />
</service>
<service name="ServiceInstancingDemo.Service3" behaviorConfiguration="SecPerCallBehaviour">
<endpoint address="~/Service3.svc"
binding="wsHttpBinding" bindingConfiguration="BindingMessageSecPerCall"
contract="ServiceInstancingDemo.IService3" />
</service>
</services>
</system.serviceModel>
</configuration>
クライアントからの構成は次のとおりです。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
<binding name="NoSecurity" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<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" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
<binding name="WSHttpBinding_IService3" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://rb-t510/NGCInstancing/Service2.svc/~/Service2.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService2"
contract="NGCWithSec.IService2" name="WSHttpBinding_IService2">
<identity>
<servicePrincipalName value="host/RB-T510" />
</identity>
</endpoint>
<endpoint address="http://rb-t510/NGCInstancing/Service1.svc/~/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="NoSecurity"
contract="NGC.IService1" name="NoSecurity" />
<endpoint address="http://localhost/NGCInstancing/Service3.svc/~/Service3.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService3"
contract="NGCSecPerCall.IService3" name="WSHttpBinding_IService3">
<identity>
<servicePrincipalName value="host/RB-T510" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
構成設定が不足していると思いますか?または、サーバー オブジェクトはセッションごとにインスタンス化する必要があり、クライアントごとに 1 つのセッションしか作成されないため、wsHttp 経由でメッセージ セキュリティを使用する複数の呼び出しは常に非常に遅くなるでしょうか?
どうもありがとう
ロブ。