How do you increase the number of threads used by .NET Remoting over TCP? How do you increase the number of threads used by .NET Remoting over TCP? asp.net asp.net

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


To sum up. A remoting server is hosted by a windows service and a remoting client by IIS. To perfrom stress tests you use Apache Bench which calls the remoting client which calls the remoting server. 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.

If all what I said is true I think that one thing is missing here i.e. IIS also has a limit of threads that can be used to handle requests. 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. I suspect that it might be a reason.

In order to increase number of threads for IIS I suggest you to try to:

  • Check configuration (see this question).
  • Try to use SetMinThreads on IIS.

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.


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. This applies to remoting, http (WCF, web service clients), etc.

You can override this under system.net/connectionManagement in your app config/web.config if this is what you are seeing, e.g.:

<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


Check your return value of 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.(link)