This is a complex issue, and as I understand this also partly depend on:
- CPU physical and logical attributes
- Process model request queue limit
- Process model maximum IO threads
- Maximum concurrent requests per CPU
- Maximum concurrent threads per CPU
I wont pretend to know much about it, I really don't. But I'm trying to understand how it works. From what I can gather I use this setup (I give absolutely no guarantees that this is the best setup):
RuntimeConfiguration.ProcessModelRequestQueueLimit = 5000 * Environment.ProcessorCount
RuntimeConfiguration.ProcessModelMaxIoThreads = 100 * Environment.ProcessorCount
HostingEnvironment.MaxConcurrentRequestsPerCPU = 5000
HostingEnvironment.MaxConcurrentThreadsPerCPU = 0
System.Net.ServicePointManager.DefaultConnectionLimit = Int32.MaxValue (well, I actually use only 48 here atm since it seems enough for my purpose and is much faster to start)
This setup is mostly based on this article:
http://blogs.msdn.com/b/tmarq/archive/2007/07/21/asp-net-thread-usage-on-iis-7-0-and-6-0.aspx