WCF 服务限制 [英] WCF Service Throttling

查看:30
本文介绍了WCF 服务限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制台应用程序中部署了一个 WCF 服务,启用了 BasicHTTPBinding 和 SSL.还设置了以下属性:

I have a WCF service deployed in a console app with BasicHTTPBinding and SSL enabled. The following attribute is set as well:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

我还将节流行为设置为

<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647"
        maxConcurrentInstances="2147483647" />

另一方面,我创建了一个测试客户端(用于负载测试),它同时启动多个客户端(多线程)并在服务器上执行事务.一切看起来都很好,但在服务器上 CPU 利用率没有增加,所以我添加了一些日志来查看对服务器的并发调用数,发现它从未超过 6.

On the other hand I have created a test client (for load test) that initiates multiple clients simultaneously (multiple threads) and performs transactions on the server. Everything seems fine but on server the CPU utilization doesn't increase so I added some logging to view the number of concurrent calls to the server and found that it never went over 6.

我已经检查了两次以上的性能计数器日志代码,对我来说似乎没问题.

I have reviewed the performance counter logging code more than twice and it seems fine to me.

所以我想问一下这种情况问题出在哪里?我还没有指定任何类型的 ContextMode 或 ConcurrencyMode.

So I want to ask where is the problem in this situation? I haven't specified any kind of ContextMode or ConcurrencyMode yet.

在这篇文章之后,我注意到每当我启动另一个测试客户端实例时,我的并发服务器调用计数器都会增加到 2,就像我只运行 1 个实例一样,最大并发 Rcvd 调用将是 2,如果有两个实例的值相同转到 4,依此类推.一次进程的 WCF 调用次数是否有限制?

After this Post I noticed that whenever i start another Intance of Test Client my concurrent Server Calls counter increase to 2 like if i am running only 1 instance the maximum Concurrent Rcvd Calls will be 2 and if there are two instance the same value goes to 4 and so on. Is there any limit of Number of WCF Calls from once process?

********于 3 月 17 日添加********

********Added on 17-March********

今天,我在运行服务器的同一台机器上对一个测试客户端(有 50 个并发用户)进行了另一项测试.这次我得到了我想要它显示的确切结果(即服务器的最大并发调用 Rcvd = 50).

Today I ran another test with one test client (with 50 concurrent users) on the same machine on which the server is running. This time I am getting the exact result what I wanted it to show (i.e. Maximum concurrent Calls Rcvd by Server = 50).

但我也需要在其他机器上做同样的事情.有人可以帮我吗?

But I need to do it the same on others machines as well. Can anybody help me on this?

推荐答案

我找到了一个解决方案:ServicePointManager 上的连接限制导致了这个问题.要取消此限制,您只需设置

I found a solution: there is a connection limit on ServicePointManager that was causing this problem. To remove this limit you just need to set

System.Net.ServicePointManager.DefaultConnectionLimit = X;

其中默认限制为 2.

这篇关于WCF 服务限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆