Home > IIS Stories > ASP.NET Threads–Tuning Thread Parameters (#2/2)

ASP.NET Threads–Tuning Thread Parameters (#2/2)

Pre-reading :

ASP.NET Threads – Thread Parameters in IIS Worker Processes

ASP.NET Threads–Tuning Thread Parameters (#1/2)

In this article, I’m going to introduce how to tune the thread parameters with its actual effects to make IIS work better.

Note : When you copy and paste any settings directly from this article to your configuration file, it can be invalid XML document, because this post includes formatted text.

Common Conditions

. A web site has many long running ASP.NET applications concurrently.
   : ‘ASP.NET vx.x\Requests Queued’ performance counter has non-zero value.

. CPU Utilzation is stable enough to add more worker threads.

Scenario #1 ASP.NET v2 (v3, or v3.5) and IIS6 (on Windows 2003)

Case 1, 
ASP.NET pages are running without calling web services via HTTP in a backend system.

: By default, you have 12x#CPU(number of processors) worker threads.

Open machince.config file in the ‘C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config’, or ‘C:\Windows\Microsoft.NET\Framework\v2.0.50727\config’ accordingly.

Create a copy of machine.config for a backup.

Find <processModel autoConfig="true"/> element, within <system.web>

Set the following values in the processModel element,

<processModel autoConfig = “false”
      maxWorkerThreads = “50”
      maxIOThreads = “50”
      minWorkerThreads = “1”
      minIoThreads = “1” />

Note that maxWorkerThreads x #CPU will be applied for a worker process(w3wp.exe).
50 is just for this example value, the default value is 12 times of #CPU(number of processors). 100 is a maximum value that you can set.

You never need to run ‘IISRESET’, or restart IIS server. Recycling related application pools is just good and enough operation to apply changes.

Case 2.
ASP.NET pages are running with consuming web services via HTTP in a backend system.

You can follow the below guildeline for this case,

Contention, poor performance, and deadlocks when you make calls to Web services from an ASP.NET application

Scenario #2 ASP.NET v2 (v3, or v3.5) and IIS7.x (on Windows 2008, or 2008 R2)

Case 3.
ASP.NET pages are running without calling web services via HTTP in a backend system.

If the application pool that you use, is set to classic mode, follow steps of Scenario #1, and Case 1 in this article. You can check this in an application pool property in IIS manager.

Open aspnet.config file in the ‘C:\Windows\Microsoft.NET\Framework64\v2.0.50727’, or ‘C:\Windows\Microsoft.NET\Framework\v2.0.50727’ accordingly.

Add the follwing ASP.NET thread parameters in aspnet.config file,




maxConcurrentRequestsPerCPU has very straightforword name as its meaning. You also can set maxConcurrentThreadsPerCPU = “50” to make similar effect, and if it’s set to 0(zero), it means it’s disabled, as above. Your web site also handles many kind of resource, non-ASPx applications, maxConcurrentRequestsPerCPU is configured in this case.

Recycle application pools to apply changes. Again, you don’t need to run IISRESET.
Now, your worker process(w3wp.exe) will be able to run 100 concurrent requests if it has 2 processors.

Case 4.
ASP.NET pages are running with consuming web services via HTTP in a backend system.

Follow the steps of Scenario#2, and Case 3 in this article to increase maxConcurrentRequestsPerCPU.

maxconnection parameter (number of network connections to the backend web server) is still limited by 12x#CPU(number of processors). So, you may need to increase maxconnection value if required, as follows,

Open machince.config file in the ‘C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config’, or ‘C:\Windows\Microsoft.NET\Framework\v2.0.50727\config’ accordingly.

Add the following parameters to machine.config file,
(You con’t need to change autoconfig to false for this parameter)


    <add address="*" maxconnection="100">


Recycle application pools to apply changes.

For debugger(WinDBG) users, if maxconnection became a bottleneck, by limiting maximum connections for a backend server, you can check this in a process dump, and run !syncblk command.

Scenario #3 ASP.NET v4 and IIS7.x (on Windows 2008, or 2008 R2)

Case 5.
ASP.NET pages are running without calling web services via HTTP in a backend system.

You have Nothing To do. In this case, number of worker threads doesn’t have foreseen value. In my test, a worker process has more than 50 threads per CPU, it’s likey to increase worker threads gradually, but it never exceed 100 threads per CPU during 30 minutes of stress test.

Although ASP.NET threads were not enough, with many requests were being queued, the total number of running requests are around 100 to 120, during most testing time. Therefore, if you want to have a configured value to be managed cleary, you can follow the steps of Scenario#2, Case 3, if necessary. But the file(aspnet.config) you need to work with, is in ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319’, or ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319’.

Case 6.
ASP.NET pages are running with consuming web services via HTTP in a backend system.

Only thing to do is increasing maxconnection value if required. You can follow steps of Case 4 in this article to increase maxconnection parameter.

The number of worker threads to handle the requests from stress test, has the same result with Case 5. But, the file(machine.config) that you need to work with, is in ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config’, or ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\config’.

In an IIS server, maxconnection in <system.net> filed of mahcine.config, is to set maximum network connections from the IIS server to a backend server. It’s not related with any connections for users who access the web site in the IIS server.

For more information,

maxConcurrentRequestsPerCPU, maxConcurrentThreadsPerCPU parameters can be configured in the Windows registry too. the path is as below,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\, or

and you can add DWORD value for each parameter.
But, you already have aspnet.config file for this.

In .NET framework v4, if you set both parameters with any values, maxConcurrentThreadsPerCPU is ignored. In addition, minFreeThreads in machine.config is ignored too, when you set autoconfig to false. It’s not simple, and easy to understand for all parameters and changes, it’s complicated, and unclear. Isn’t it?

In Summary,

The thread parameters in machine.config can be applied for all version of IIS, and .NET framework, however, in IIS7.x, ASP.NET parameters in ASPNET.CONFIG file can replace the tuning parameters in machine.config file. maxConcurrentRequestsPerCPU can be useful to make this simple.

If your ASP.NET applications are calling remote web services(using *.asmx for example), you also need to tune the backend servers accordingly to enhance the system concurrency.

maxconnection value is 12 by #CPU, and it hasn’t changed in IIS7.x. You can add this tuned parameter in a machine.config file, and it’s not required to change ‘autoconfig’ to false for this parameter. autoconfig is for parameters in processmodel elements.


ASP.NET Thread Usage on IIS 7.5, IIS 7.0, and IIS 6.0

Categories: IIS Stories
  1. 2017/01/07 at 9:04 pm

    J’ai oublié je suis fan de ta page facebook (Juliette LouMaloé) et je suis inscrite à ta newsletter… Comme ça je suis sur de ne louper aucune de tes actualités…!! Merci encore pour ce concours!!
    hostil http://www.1001telecommandes.com/


  1. 2017/12/18 at 8:01 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: