How to tune machine.config settings for improved performance

machine.config

machine.config

Explore ways to tweak the settings in machine.config file for improved performance

RELATED TOPICS

Tweaking the settings in your configuration files in ASP.Net can provide a nice performance boost. These files include machine.config and web.config.

The web.config file is application-specific and is created by default when you create a web application or a web site in Visual Studio. Note that there is another config file named aspnet.config -- it is available from ASP.Net 2.0 onwards. This file is available in the root of the .Net Framework folder in your system. The machine configuration file, meanwhile,  is named machine.config and resides in the %runtime install path%\Config directory.

While the settings in the web.config file apply only to the application, the settings present in the machine.config file are applicable machine-wide. Note that the machine.config file is installed when you install .Net Framework in your system. You can have only one machine.config file in your system (one per system only) and it resides in the \WINDOWS\Microsoft.Net\Framework\vXXXX\CONFIG directory.

It should be noted that the settings defined in the machine.config file is overridden by those defined in the web.config file in your application. An application can have multiple web.config files. Incidentally, the web.config file inherits the settings defined in the machine.config.

Recommended machine.config settings

In this section we will explore the settings that can be applied to the machine.config file for performance gains. Note that the default and recommended values have been specified against each setting.

maxconnection

You can tweak the system.Net settings in your machine.config file to allow more concurrent requests to be served by your application. The default value is 2 while the recommended value is 12 per CPU.

<system.Net>

    <connectionManagement>

        <add address="*" maxconnection="24"/>

    </connectionManagement>

</system.Net>

Here are the recommended settings for the process model section in your machine.config file for performance benefits. You can tweak the settings in the process model in your machine.config file to control worker threads, I/O threads, etc. Note that a thread is the smallest unit of execution within a process.

memoryLimit

This setting is used to specify the percentage of the total system memory that the process would use. The default value is 40. The recommended value for this setting depends on many factors. Such considerations include (but are not limited to) the following:

  • If the application is installed in an isolated box
  • Occurrence of memory leaks in the application

maxWorkerThreads

This setting is used to define the maximum number of worker threads that are available in the thread pool at any given point of time. A thread pool comprises of a number of threads, or, a collection of threads to be precise, and it can be used to perform several activities in the background. The MSDN states: "A thread pool is a collection of worker threads that efficiently execute asynchronous callbacks on behalf of the application. The thread pool is primarily used to reduce the number of application threads and provide management of the worker threads."

The default value of maxWorkerThreads is 20 per CPU and the recommended value is 100.

minWorkerThreads

This setting determines the minimum number of worker threads that are available in the thread pool to satisfy an incoming request. The default value is 1 while the recommended value is maxWorkerThreads / 2. So if you have defined maxWorkerThreads as 100 in your machine.config file, you should specify 50 as minWorkerThreads.

maxIOThreads

This setting is used to define the maximum number of threads that are allotted for performing input output (I/O) operations. Such operations include database operations, calls to web services, accessing the file system, etc. The default value is 20 per CPU while a value of 100 is recommended.

minIOThreads

This is used to define the minimum number of I/O threads that are available in the thread pool at a particular point of time. The default value is 1 while the recommended value is maxIOThreads / 2. So, if you have defined maxIOThreads as 100 in your machine.config file, you should mention 50 as minIOThreads.

Put it all together

Let's now put all of these settings to work. The following code listing illustrates the typical settings in a machine.config file based on the recommended settings described earlier in the article.

<configuration>

 <system.Net>

         <connectionManagement>

             <add address="*" maxconnection="24" />

         </connectionManagement>

     </system.Net>

     <system.web>

         <processModel autoConfig="true"

             maxWorkerThreads = "100"

             maxIoThreads = "100"

             minWorkerThreads = "50"

             minIoThreads = "50"

         />

     </system.web>

</configuration>

This article is published as part of the IDG Contributor Network. Want to Join?

RELATED TOPICS
From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies