简体   繁体   English

如何通过TCP增加.NET Remoting使用的线程数?

[英]How do you increase the number of threads used by .NET Remoting over TCP?

We are trying to increase the number of threads used by .NET Remoting over TCP. 我们正在尝试通过TCP增加.NET Remoting使用的线程数。 We have tried changing the ThreadPool.SetMinThreads, but our stress tests show that .NET Remoting can only handle about 100 concurrent requests. 我们尝试更改ThreadPool.SetMinThreads,但是我们的压力测试显示.NET Remoting只能处理大约100个并发请求。 (However this is not a hard limit). (但这不是硬限制)。 In Task Manager, we can see our Remoting Server process Thread count grow from 11 to about 80, which then drops back down to 11 after the stress test. 在任务管理器中,我们可以看到我们的远程处理服务器进程线程数从11增加到大约80,然后在压力测试后下降到11。 We are running an ASP.NET 4.0 application. 我们正在运行ASP.NET 4.0应用程序。

To sum up. 总结一下。 A remoting server is hosted by a windows service and a remoting client by IIS. 远程服务器由IIS服务和远程客户端由IIS托管。 To perfrom stress tests you use Apache Bench which calls the remoting client which calls the remoting server. 要进行压力测试,请使用Apache Bench调用远程客户端调用远程服务器。 You observe that no more than 100 concurrent requests is processed by the remoting server although you increase maximum number of threads in a thread pool on the remoting server. 您发现远程服务器处理的并发请求不超过100个,尽管您增加了远程服务器上线程池中的最大线程数。

If all what I said is true I think that one thing is missing here ie IIS also has a limit of threads that can be used to handle requests. 如果我所说的都是真的,我认为这里缺少一件事,即IIS也有一个可用于处理请求的线程限制。 You can send 1000 request from Apache Bench to the remoting client but only, for example 100 of them will be handled at the same time. 您可以从Apache Bench向远程客户端发送1000请求,但仅限于,例如,其中100个将同时处理。 I suspect that it might be a reason. 我怀疑这可能是一个原因。

In order to increase number of threads for IIS I suggest you to try to: 为了增加IIS的线程数,我建议您尝试:

  • Check configuration (see this question ). 检查配置(请参阅此问题 )。
  • Try to use SetMinThreads on IIS. 尝试在IIS上使用SetMinThreads

The last comment from my side is that you have to remember that neither too small number of threads nor too high number of threads in a thread pool is good. 我方的最后一点评论是你必须记住,线程池中线程数量太少,线程数量太多也不好。 Both situations can hurt performance. 两种情况都会影响性能。

Check your return value of SetMinThreads. 检查SetMinThreads的返回值

If you specify a negative number or a number larger than the maximum number of active thread pool threads (obtained using GetMaxThreads), SetMinThreads returns false and does not change either of the minimum values. 如果指定负数或大于活动线程池线程的最大数量(使用GetMaxThreads获取),则SetMinThreads将返回false并且不会更改任一最小值。 ( link ) 链接

Are you sure the bottleneck is threads, and not network connections..? 确定瓶颈是线程,而不是网络连接..? By default, .net has a fairly limited number of sockets available per remote IP. 默认情况下,.net每个远程IP可用的插槽数量相当有限。 This applies to remoting, http (WCF, web service clients), etc. 这适用于远程处理,http(WCF,Web服务客户端)等。

You can override this under system.net/connectionManagement in your app config/web.config if this is what you are seeing, eg: 您可以在app config / web.config中的system.net/connectionManagement下覆盖此项,如果这是您所看到的,例如:

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

More details about that config setting can be found here: https://msdn.microsoft.com/en-us/library/fb6y0fyc%28v=vs.110%29.aspx 有关该配置设置的更多详细信息,请访问: https//msdn.microsoft.com/en-us/library/fb6y0fyc%28v=vs.110%29.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM