Content area
Full Text
In the .Net Framework, the CLR is responsible for meting out resources to running applications. In particular, the CLR thread pool determines when threads are to be added or taken away. Understanding how this works will help you determine how to configure your ASP.Net application for optimal performance.
The CLR thread pool contains two kinds of threads-the worker threads and the I/O completion port or IOCP threads. That means your ASP.Net worker process actually contains two thread pools: the worker thread pool and the IOCP thread pool. Naturally, these pools have different purposes.
When you use methods like Task.Run, TaskFactory.StartNew, and ThreadPool.QueueUserWorkItem, the runtime takes advantage of worker threads for processing. When you make asynchronous I/O calls in your application, or your application accesses the file system, databases, web services, etc., then the runtime uses IOCP threads. Note too that each application domain has its own thread pool.
[ Discover the power of Bash on Windows. | The power of PowerShell: PowerShell intro for Windows Server admins [bullet] PowerShell intro for Exchange admins [bullet] Essential PowerShell scripts for security admins [bullet] All about PowerShell providers and modules. | Keep up with hot topics in programming with InfoWorld’s App Dev Report newsletter. ]
Let’s take a closer look at how these threads are created and removed in the .Net Framework.
Thread injection strategies
The .Net thread pool starts injecting new threads whenever the number of busy threads becomes equal to the number...