如何增加WCF服务的并行连接数
我们的Web应用程序存在性能问题,我正在调查。它使用一个4层架构,包含MVC4 Web应用程序,WCF数据服务和SQLServer作为数据库。 虽然有足够的可用资源,但数据服务并未真正扩展请求。它似乎只能并行处理10-12个请求,并排队所有其他请求。我希望看到它同时回答> 100个请求。如何增加WCF服务的并行连接数
- 我想玩弄我发现 这个话题WCF所有配置值:system.net - > connectionManagement - >添加 MAXCONNECTION = 100 serviceBehavior - > serviceThrottling - > maxConcurrentCalls /实例/会话= 100。没有成功。
- 我试图使用httpBinding以及netTcpBinding,我发现 参数maxConnections并将其设置为100.没有成功。
- 它是WCF吗?我实现了一个简单的sleep.aspx webform,它有1s到 return(使用Thread.Sleep())。相同的结果,只有10-12个请求是 在1秒内回答,进一步的请求排队。
- 它是.Net吗?我在testmachine上安装了ActiveState Perl,并且编写了一个Perl脚本,它的功能相同。相同结果,10-12 请求会直接回答,其他人则会排队。
- 它是Windows吗?我使用 Apache在Linux机器上安装了Perl脚本。测试客户端在Windows下运行。在这个星座中,当我将Apache配置为拥有尽可能多的服务器进程时,I 可在1秒内得到100个响应。
- IIS也能够使用多个进程而不是多个线程(Web园林)运行。啊,在这种情况下,IIS也会并行回答100 个请求。
这一切都让我得出结论:单个Windows进程可能无法并行处理超过10-12个TCP连接。
这是事实吗?这可以配置在某个地方吗?
由于数据服务的设计,它不应该与多个进程一起运行,因为它使用了需要与所有其他实例同步的对象高速缓存。
谷歌似乎不太了解这个问题。
环境:在Windows Server 2008 R2/Windows Server 2012中R2,MVC4,WCF,净4.5.1
Thomy
有几件事情,你可以尝试
中添加服务行为以最大程度的发挥呼叫量,它可以处理
<serviceBehaviors>
<behavior name="StandardServiceBehavior">
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="10000"/>
</behavior>
</serviceBehaviors>
您是否尝试过与服务行为的并发模式打转转?
服务行为或许设置为
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode。多个)]
请参阅此设置在此处执行的完整说明。
http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode(v=vs.110).aspx
你可能也想尝试添加一些日志记录WCF服务,看到这个链接
http://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx
它应该给你一个更深入的了解什么是真正回事,是否有任何错误。有时我也看到,如果maxconcurrentcalls已被击中,它会将呼叫排队到服务,这些都显示为警告。
<serviceBehaviors>
<behavior name="defaultServiceBehavior">
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentInstances="100" maxConcurrentSessions="100" />
</behavior>
</serviceBehaviors>
下面是这些设置的摘要:
maxConcurrentCalls: defines the maximum number of messages actively processed by all the service instances of a ServiceHost. The default value is 16. Calls in excess of the limit are queued.
maxConcurrentInstances: defines the maximum number of service instances that can execute at the same time. The default value is Int32.MaxValue. Requests to create additional instances are queued and complete when a slot below the limit becomes available.
maxConcurrentSessions: defines the maximum number of sessions that a ServiceHost instance can accept at one time. The default value is 10. The service will accept connections in excess of the limit, but only the channels below the limit are active (messages are read from the channel).
serviceBehaviors是WCF配置选项,使用webforms甚至perl脚本可以看到相同的行为。更改这些设置不起作用,我无法提高并行度。 – Thomy 2014-09-15 05:55:39
Windows进程可以处理超过10-12连接。如果我诚实的话,它听起来像是你打maxConcurrentCalls。 – RockThunder 2014-09-11 12:59:06
感谢您的回复,我尝试使用ConcurrencyMode和maxConcurrentCalls,但很少成功。可以进一步降低并行性,但我无法增加它。 – Thomy 2014-09-15 05:52:02