[英]How to increase the number of parallel connections for a WCF service
Our web application has performance problems which I am investigating. 我们的Web应用程序存在我正在调查的性能问题。 It uses a 4-tier architecture with a MVC4 webapp, WCF data service and SQLServer as DB.
它使用具有MVC4 Web应用程序,WCF数据服务和SQLServer作为DB的4层体系结构。 The data service does not really scale the requests although there are enough resources available.
尽管有足够的可用资源,但是数据服务并没有真正扩展请求。 It seems that it only answers 10-12 requests in parallel and queues all others.
似乎它只能并行回答10-12个请求,并将所有其他请求排队。 I would like to see that it answers >100 requests simultaneously.
我希望看到它可以同时回答100多个请求。
All this brings me to the conclusion that a single Windows process might not be able to handle more than 10-12 TCP connection in parallel. 所有这些使我得出的结论是,单个Windows进程可能无法并行处理超过10-12个TCP连接。
Is this the truth? 这是事实吗? Can this be configured somewhere?
可以在某个地方配置它吗?
Due to the design of the data service it should not run with multiple processes because it uses an object cache which needs to be synchronized with all other instances. 由于数据服务的设计,它不应与多个进程一起运行,因为它使用的对象缓存需要与所有其他实例同步。
Google seems not to know much about this issue. Google似乎对这个问题不太了解。
Environment: Windows Server 2008 R2/Windows Server 2012 R2, MVC4, WCF, .Net 4.5.1 环境:Windows Server 2008 R2 / Windows Server 2012 R2,MVC4,WCF,.Net 4.5.1
Thomy omy
<serviceBehaviors>
<behavior name="defaultServiceBehavior">
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentInstances="100" maxConcurrentSessions="100" />
</behavior>
</serviceBehaviors>
Here's a summary of these settings: 以下是这些设置的摘要:
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).
There are several things you can try 您可以尝试几种方法
Add a service behaviour in to max out the amount of calls it can handle 添加服务行为以最大程度地处理服务数量
<serviceBehaviors>
<behavior name="StandardServiceBehavior">
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="10000"/>
</behavior>
</serviceBehaviors>
Have you tried playing around with the Concurrency mode in the service behaviour? 您是否尝试过在服务行为中使用并发模式?
maybe setting the service behaviour to 也许将服务行为设置为
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
see the full explanation to what this setting does here. 请参阅此处对此设置的完整说明。
http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode(v=vs.110).aspx http://msdn.microsoft.com/zh-CN/library/system.servicemodel.concurrencymode(v=vs.110).aspx
You might also want to try adding in some logging for your wcf service, see this link 您可能还想尝试为wcf服务添加一些日志记录,请参见此链接
http://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx http://msdn.microsoft.com/zh-CN/library/ms730064(v=vs.110).aspx
It should give you a deeper insight into what is actually going on and whether there are any errors. 它应该使您对实际发生的情况以及是否有任何错误有更深入的了解。 Also sometimes I have seen if the maxconcurrentcalls has been hit it will queue the calls to the service, these are displayed as warnings.
有时我还看到maxconcurrentcalls是否被命中,它将使对服务的调用排队,这些显示为警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.