I have a general question about System.Threading.Threadpool when run in a webapplication on IIS. Say we have 2 requests execute at once, and we fire up a couple of threads through the ThreadPool.QueueUserWorkItem method. Will the two requests share the ThreadPool, or will the calls to the ThreadPool from the two requests operate in a two separate pools?
This is in IIS6 and 7.
Thanks for any insight.
To change how the IIS thread pool works, and how many threads it provides for your workload, you can modify a number of registry values under the registry key HKLM\System\CurrentControlSet\Services\InetInfo\Parameters. The configured maximum number of threads (per processor) in the IIS thread pool.
Consider using asynchronous operations to avoid threads altogether. Agree with SLaks, indeed IIS by default will use 12 threads, however almost any dynamic content you have (whether PHP, ASP.NET, etc) will have their own thread pool that in some ways makes the specific answer of 12 threads not interesting.
Click to expand Limits Properties under Behavior, click Threads Per Processor Limit, enter the desired value for Threads Per Processor Limit and click Apply in the Actions pane.
Can I use multiple worker processes in my IIS Application Pools? No. The 'moveitdmz ISAPI Pool' and the 'moveitdmz Pool' should each be set to use only 1 worker process. If this number is increased, you will most likely see unusual behavior on your DMZ system.
Here is a quote from the MSDN documentation about the ThreadPool class:
There is one thread pool per process. The thread pool has a default size of 250 worker threads per available processor, and 1000 I/O completion threads.
In IIS6 and IIS7 any given ASP.NET application is hosted inside of a single process (w3wp.exe) through the Application Pool infrastructure.
An Application Pool can host multiple web applications by keeping them in different AppDomains, but it runs inside of one physical process on the server.
These two facts mean in practice that all threads from a running web application instance execute inside the same .NET Thread Pool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With