Explore ways to tweak the settings in machine.config file for improved performance 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 WINDOWSMicrosoft.NetFrameworkvXXXXCONFIG 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> Related content feature What is Rust? Safe, fast, and easy software development Unlike most programming languages, Rust doesn't make you choose between speed, safety, and ease of use. Find out how Rust delivers better code with fewer compromises, and a few downsides to consider before learning Rust. By Serdar Yegulalp Nov 20, 2024 11 mins Rust Programming Languages Software Development how-to Kotlin for Java developers: Classes and coroutines Kotlin was designed to bring more flexibility and flow to programming in the JVM. Here's an in-depth look at how Kotlin makes working with classes and objects easier and introduces coroutines to modernize concurrency. By Matthew Tyson Nov 20, 2024 9 mins Java Kotlin Programming Languages analysis Azure AI Foundry tools for changes in AI applications Microsoft’s launch of Azure AI Foundry at Ignite 2024 signals a welcome shift from chatbots to agents and to using AI for business process automation. By Simon Bisson Nov 20, 2024 7 mins Microsoft Azure Generative AI Development Tools news Microsoft unveils imaging APIs for Windows Copilot Runtime Generative AI-backed APIs will allow developers to build image super resolution, image segmentation, object erase, and OCR capabilities into Windows applications. By Paul Krill Nov 19, 2024 2 mins Generative AI APIs Development Libraries and Frameworks Resources Videos