ASP.Net 并通过打开连接监听事件 - 是否可以增加并发执行线程的数量?

发布于 2024-11-07 09:48:53 字数 4031 浏览 0 评论 0原文

我正在尝试使用 IIS 托管事件驱动的 Web 应用程序。假设我想将它用于聊天类型的应用程序。

我不想每秒左右轮询一次(延迟),而是想与我的应用程序保持一个开放的连接,一旦有可用数据,该连接就会返回。

问题是我无法让超过 10 个并发线程执行。

我已将 MaxThreads 设置为 5000/5000,MaxConcurrentRequestsPerCpu 设置为 5000,QueueLimit 默认为 5000,MaxConcurrentThreadsPerCPU 为 0(无界)。

唯一的问题是 DefaultConnectionLimit 默认情况下似乎是 12,而且我似乎无法在 web.config 中更改它。我已设法在 global.asax Application_Start 中设置它,但我不知道此时设置它是否为时已晚。它在文档中说它不会影响已经初始化的 ServicePoints。

<system.net>
  <connectionManagement>
     <add address="*" maxconnection="100" />
  </connectionManagement>
</system.net>

以上是我的 web.config 中的内容(涉及 DefaultConnectionLimit)。

5/14/2011 3:34:45 PM with timediff 0         :  Entered method with threadId: 6, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500
5/14/2011 3:34:45 PM with timediff 0         :  Entered method with threadId: 5, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500
5/14/2011 3:34:46 PM with timediff 0.5       :  Entered method with threadId: 7, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4997 and DefaultConnectionLimit is 1500
5/14/2011 3:34:47 PM with timediff 1.5       :  Entered method with threadId: 8, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4996 and DefaultConnectionLimit is 1500
5/14/2011 3:34:48 PM with timediff 2.5       :  Entered method with threadId: 9, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4995 and DefaultConnectionLimit is 1500
5/14/2011 3:34:49 PM with timediff 3.5       :  Entered method with threadId: 10, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4994 and DefaultConnectionLimit is 1500
5/14/2011 3:34:50 PM with timediff 4.5       :  Entered method with threadId: 12, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4993 and DefaultConnectionLimit is 1500
5/14/2011 3:34:51 PM with timediff 5.5       :  Entered method with threadId: 13, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4992 and DefaultConnectionLimit is 1500
5/14/2011 3:34:52 PM with timediff 6.5       :  Entered method with threadId: 14, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4991 and DefaultConnectionLimit is 1500
5/14/2011 3:34:52 PM with timediff 7         :  Entered method with threadId: 15, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4990 and DefaultConnectionLimit is 1500
5/14/2011 3:36:45 PM with timediff 120       :      Exiting method with threadId: 6
5/14/2011 3:36:45 PM with timediff 120       :      Exiting method with threadId: 5
5/14/2011 3:36:46 PM with timediff 120.5     :      Exiting method with threadId: 7
5/14/2011 3:36:47 PM with timediff 121.5     :      Exiting method with threadId: 8
5/14/2011 3:36:48 PM with timediff 122.5     :      Exiting method with threadId: 9
5/14/2011 3:36:49 PM with timediff 123.5     :      Exiting method with threadId: 10

以上是我为测试线程并发性而生成的日志文件的摘录。它只是一个 MVC 操作方法,其中有 120 秒的睡眠时间。 Timediff 是第一个请求与当前记录的请求之间的差异。

正如您所看到的,AvailableThreads 下降到 4990,然后等待其他线程退出才继续。请求之间的延迟似乎是 Fiddlers 的错误(我用它来进行负载测试)。

我也尝试过 BadBoy 发出相同的请求,它也受到 10 个线程的限制。

这是因为连接来自同一客户端吗?我还错过了其他限制吗?诚然,用不同的主机进行负载测试是很困难的。

I am trying to use IIS to host an event-driven web-application. Lets say I want to use it for a chat-type application.

Instead of polling once every second or so (delay) I want to leave an open connection to my application which returns once there is data available.

The problem is that I can't get more than 10 concurrent threads executing.

I've set MaxThreads to 5000/5000, MaxConcurrentRequestsPerCpu to 5000, QueueLimit is 5000 by default, MaxConcurrentThreadsPerCPU is 0 (unbounded).

The only thing is that DefaultConnectionLimit seems to be 12 by default, and I can't seem to change it in my web.config. I've managed to set it in global.asax Application_Start but I don't know if it is too late to set it at that point. It says in the documentation that it does not affect already initialized ServicePoints.

<system.net>
  <connectionManagement>
     <add address="*" maxconnection="100" />
  </connectionManagement>
</system.net>

The above is what I have in my web.config (that concerns DefaultConnectionLimit).

5/14/2011 3:34:45 PM with timediff 0         :  Entered method with threadId: 6, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500
5/14/2011 3:34:45 PM with timediff 0         :  Entered method with threadId: 5, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500
5/14/2011 3:34:46 PM with timediff 0.5       :  Entered method with threadId: 7, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4997 and DefaultConnectionLimit is 1500
5/14/2011 3:34:47 PM with timediff 1.5       :  Entered method with threadId: 8, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4996 and DefaultConnectionLimit is 1500
5/14/2011 3:34:48 PM with timediff 2.5       :  Entered method with threadId: 9, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4995 and DefaultConnectionLimit is 1500
5/14/2011 3:34:49 PM with timediff 3.5       :  Entered method with threadId: 10, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4994 and DefaultConnectionLimit is 1500
5/14/2011 3:34:50 PM with timediff 4.5       :  Entered method with threadId: 12, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4993 and DefaultConnectionLimit is 1500
5/14/2011 3:34:51 PM with timediff 5.5       :  Entered method with threadId: 13, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4992 and DefaultConnectionLimit is 1500
5/14/2011 3:34:52 PM with timediff 6.5       :  Entered method with threadId: 14, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4991 and DefaultConnectionLimit is 1500
5/14/2011 3:34:52 PM with timediff 7         :  Entered method with threadId: 15, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4990 and DefaultConnectionLimit is 1500
5/14/2011 3:36:45 PM with timediff 120       :      Exiting method with threadId: 6
5/14/2011 3:36:45 PM with timediff 120       :      Exiting method with threadId: 5
5/14/2011 3:36:46 PM with timediff 120.5     :      Exiting method with threadId: 7
5/14/2011 3:36:47 PM with timediff 121.5     :      Exiting method with threadId: 8
5/14/2011 3:36:48 PM with timediff 122.5     :      Exiting method with threadId: 9
5/14/2011 3:36:49 PM with timediff 123.5     :      Exiting method with threadId: 10

The above is an excerpt from the log file I am producing to test thread concurrency. It is simply an MVC action method with a 120 second sleep in it. Timediff is the difference from first request to the current request being logged.

As you can see, AvailableThreads dip down to 4990, and then waits for the other threads to exit before continuing. The delay between requests seems to be Fiddlers fault (which I use to load test).

I've also tried BadBoy to issue the same requests, and it also suffers from the 10 thread limit.

Is this because the connections are from the same client? Is there some other limit I have missed? It's admittedly difficult to load-test with different hosts..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狂之美人 2024-11-14 09:48:53

如果您在 Windows 7 下测试您的应用程序。它有 10 个并发连接限制。此外,您可能会发现 (IISTuner) 很有用。

If you test your application under Windows 7. It has 10 concurrent connections limit. Additionally, you may find (IISTuner) useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文