我们有一个跨两台服务器负载均衡的网站,这些服务器调用一个IIS7应用服务器上托管的WCF wsHttp服务。WCF消息安全 - PerCall
上周,该网站推出,我们遇到了性能问题。
该系统由一个离岸团队构建,但我被要求调查是否可以提供帮助。
我加载了perfmon并使用asp.net计数器来查看当前会话。我可以看到,一旦这个数字增加到大约25以上,那么网站就会大大减慢。在接下来的10分钟内,它会继续增加到250,然后降到0,并且网站的性能会很好。
这在一个循环中继续 - 坏消息!
第二天,离岸团队告诉我他们通过调整安全来解决问题。
我有一个理论,在禁用wsHttp绑定WCF的安全性从创建一个实例每个会话更改为每个调用创建一个实例 - 因此允许更大的吞吐量的服务请求。这是一个好理论吗?
我已经构建了一个简单的模型来测试这个,IIS中的几个方法以及一个生成多个请求的简单客户端。这似乎给我预期的结果。问题是,我正在努力寻找正确的性能计数器,以证明当不使用安全绑定时,更少的请求排队并创建更多的并发实例。
任何人都可以请建议最好的perfmon计数器使用?
好的,今天又有一天这个和更多的问题!
在我的测试应用程序,我现在有3个不同的wsHttp绑定
- 没有安全
- 信息安全
- 信息安全但3服务类[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]在类上设置
从客户端的40循环中,我启动一个新线程并调用该服务。在调用服务1时,服务在1秒内完成所有请求。
当调用服务2时,服务在33秒内完成所有请求。
当调用服务3时,我期望它和服务1几乎一样快,因为我期望服务为4个调用中的每一个实例化一个新的服务对象。但是,它似乎并没有(我仍然没有任何有意义的性能计数器!)来完成这个任务,并且完成时间也是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>
我想,我错过一个配置设置?或者也许使用wsHttp上的消息安全的多次调用总是会很慢,因为服务器对象必须在每个会话中实例化,并且每个客户端只创建一个会话?
非常感谢
Rob。
嗨,我已经启用了计数器在WCF配置。问题是,perfmon中没有可用的计数器似乎给我所需的信息 - 比如创建的实例的数量。 –
Ernie,这是一个有用的链接 - 谢谢。 –
在perfmon中选择:ServiceModelService 4.0.0.0 - > Instances - >。点击确定。现在在“实例”列表中查找您的服务。 –
ErnieL