WCF服务行为
我有一个自我托管的WCF服务,我正在Windows服务中托管。我的绑定设置为basicHttpBinding 当我运行服务时,我运行netshhttpshowservicestate,我看到我的服务正在侦听;但是,我似乎无法正确配置参数 当在IIS下托管时,它的执行速度大约慢20%,所以我想自行托管。如何配置自托管WCF服务的参数以匹配IIS?我特别关注的参数是超时、最大连接、超时和最大请求。我试图将一个服务行为;然而,它什么也不做。我在注册表中的HTTP/Parameters下添加了MaxConnections,也没有运气。感谢您的帮助 以下是在IIS下托管时的输出:WCF服务行为,wcf,wcf-binding,http.sys,Wcf,Wcf Binding,Http.sys,我有一个自我托管的WCF服务,我正在Windows服务中托管。我的绑定设置为basicHttpBinding 当我运行服务时,我运行netshhttpshowservicestate,我看到我的服务正在侦听;但是,我似乎无法正确配置参数 当在IIS下托管时,它的执行速度大约慢20%,所以我想自行托管。如何配置自托管WCF服务的参数以匹配IIS?我特别关注的参数是超时、最大连接、超时和最大请求。我试图将一个服务行为;然而,它什么也不做。我在注册表中的HTTP/Parameters下添加了MaxCo
Server session ID: F9000000200015DA
Version: 2.0
State: Active
Properties:
Max bandwidth: 4294967295
Timeouts:
Entity body timeout (secs): 120
Drain entity body timeout (secs): 120
Request queue timeout (secs): 65535
Idle connection timeout (secs): 120
Header wait timeout (secs): 120
Minimum send rate (bytes/sec): 240
URL groups:
URL group ID: F600000040001737
State: Active
Request queue name: MyService
Properties:
Max bandwidth: inherited
Max connections: 4294967295
Timeouts:
Entity body timeout (secs): 120
Drain entity body timeout (secs): 120
Request queue timeout (secs): 65535
Idle connection timeout (secs): 120
Header wait timeout (secs): 0
Minimum send rate (bytes/sec): 0
Logging information:
Log directory: C:\inetpub\logs\LogFiles\W3SVC2
Log format: 0
Authentication Configuration:
Authentication schemes enabled:
Number of registered URLs: 1
Registered URLs:
HTTP://*:80/
Request queues:
Request queue name: MyService
Version: 2.0
State: Active
Request queue 503 verbosity level: Basic
Max requests: 3000
Number of active processes attached: 1
Controller process ID: 1400
Process IDs:
以下是我自托管时的输出:
Server session ID: FC00000120000229
Version: 2.0
State: Active
Properties:
Max bandwidth: 4294967295
Timeouts:
Entity body timeout (secs): 120
Drain entity body timeout (secs): 120
Request queue timeout (secs): 120
Idle connection timeout (secs): 120
Header wait timeout (secs): 120
Minimum send rate (bytes/sec): 150
URL groups:
URL group ID: FB000001400005DE
State: Active
Request queue name: Request queue is unnamed.
Properties:
Max bandwidth: inherited
Max connections: inherited
Timeouts:
Timeout values inherited
Number of registered URLs: 1
Registered URLs:
HTTP://+:80/MyService/
Request queues:
Request queue name: Request queue is unnamed.
Version: 2.0
State: Active
Request queue 503 verbosity level: Basic
Max requests: 1000
这是我的服务配置文件:
<?xml version="1.0"?> <configuration> <system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyThrottle">
<serviceThrottling maxConcurrentCalls="3000" maxConcurrentSessions="3000"
maxConcurrentInstances="12500" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyConfig" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxReceivedMessageSize="10485760" useDefaultWebProxy="false">
<readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyThrottle" name="This.MyService">
<endpoint address="http://localhost:80/MyService" binding="basicHttpBinding"
bindingConfiguration="MyConfig" name="MyService"
contract="This.IMyService" />
</service>
</services> </system.serviceModel> </configuration>
以下是Microsoft HTTP.SYS团队的官方回复: “最大连接数”=HttpServerConnectionsProperty输出的含义与“最大请求数”=HttpServerQueueLengthProperty不同
HttpListener不允许您为URL组设置最大连接属性(HttpServerConnectionsProperty)或为请求队列设置最大请求属性(HttpServerQueueLengthProperty),因此WCF在通过代码自托管时无法设置http.sys设置 您能显示执行自托管的代码吗?
ServiceHost serverSyncHost=newservicehost(typeof(This.MyService));serverSyncHost.Faulted+=新的EventHandler(serverSyncHost\u出现故障);serverSyncHost.Open()
所以问题是,您在配置文件中有您需要的所有设置,但当您在windows服务中托管您的服务时,这些设置没有应用?经过数小时的研究;我想我没有做到的是设置HTTP.SYS驱动程序的最大请求数。在IIS下托管时,这是在应用程序池中设置的。当自我托管时,我不确定在哪里设置它。简单的答案是IIS下的主机;但是,在性能测试时,自托管大约快20%。