title: ASP.NET not using all worker threads
body: <p>It looks like my setup of ASP.NET does not use more than 10 worker threads. I've followed recommendations from this article to no avail: <a href="http://support.microsoft.com/kb/821268" rel="nofollow">http://support.microsoft.com/kb/821268</a>. I know about asynchronous controllers, but using them is not realistic in our case.</p>
  
  <p>I have the following ASP.NET MVC action method to test thread contention:</p>
  
  <pre><code>public ActionResult Index()
  {
      int workers;
      int io;
  
      ThreadPool.GetAvailableThreads(out workers, out io);
  
      Thread.Sleep(1000);
  
      return Content(workers.ToString());
  }
  </code></pre>
  
  <p>It returns 399 by default (399 unused threads in the thread pool - 4 processors * 100). When I load this method with jmeter, I see that this figure never goes below 390. I also see that response times start to increase linearly if I have more than 10 virtual sessions, that is you can clearly observe thread contention. How can I force ASP.NET (or .NET) use more of thread pool threads?</p>
  
  <p>EDIT:
  After I changed <code>Thread.Sleep</code> with <code>await WebClient.DownloadStringTaskAsync</code> (requesting remote computer http resource), the situation has become even more interesting. Now, number of available thread pool threads mostly remains to be 399 (although it went to 386 at one point). It is expected, since there is no computation to make by .NET. I also wrapped action method with Stopwatch and see that time spent in the method remains constant.
  It looks like it's not a .NET ThreadPool issue, but some IIS or ASP.NET connection limit issue, although I see the following in my Web.config:</p>
  
  <pre><code>  &lt;system.net&gt;
      &lt;connectionManagement&gt;
        &lt;add address="*" maxconnection="100" /&gt;
      &lt;/connectionManagement&gt;
    &lt;/system.net&gt;
  </code></pre>