Sometimes when you want to quickly tune asp.net application the following points can be checked (not in any particular order) as it requires minimal code changes to the application.
- 1. Analyze Database while running the application, via sql profiler. Identify which stored procedures are called and whether the database tables are properly indexed. And queries not performing Full table scan for any case.
- 2. Recommended Threading Settings for Reducing Contention
Configuration setting Default value (.NET Framework 1.1) Recommended value
maxconnection 2 12 * #CPUs
maxIoThreads 20 100
maxWorkerThreads 20 100
minFreeThreads 8 88 * #CPUs
minLocalRequestFreeThreads 4 76 * #CPUs
To address this issue, you need to configure the following items in the Machine.config file.
* Set maxconnection to 12 * # of CPUs. This setting controls the maximum number of outgoing HTTP connections that you can initiate from a client. In this case, ASP.NET is the client. Set maxconnection to 12 * # of CPUs.
* Set maxIoThreads to 100. This setting controls the maximum number of I/O threads in the .NET thread pool. This number is automatically multiplied by the number of available CPUs. Set maxloThreads to 100.
* Set maxWorkerThreads to 100. This setting controls the maximum number of worker threads in the thread pool. This number is then automatically multiplied by the number of available CPUs. Set maxWorkerThreads to 100.
* Set minFreeThreads to 88 * # of CPUs. This setting is used by the worker process to queue all the incoming requests if the number of available threads in the thread pool falls below the value for this setting. This setting effectively limits the number of requests that can run concurrently to maxWorkerThreads – minFreeThreads. Set minFreeThreads to 88 * # of CPUs. This limits the number of concurrent requests to 12 (assuming maxWorkerThreads is 100).
* Set minLocalRequestFreeThreads to 76 * # of CPUs. This setting is used by the worker process to queue requests from localhost (where a Web application sends requests to a local Web service) if the number of available threads in the thread pool falls below this number. This setting is similar to minFreeThreads but it only applies to localhost requests from the local computer. Set minLocalRequestFreeThreads to 76 * # of CPUs.
- 3. Make sure Asp.Net application not running in debug mode. Make sure in web.config debug attribute is set to false .
- 4. Make sure buffer is enabled. Normally by default it’s enabled.
Enable buffering at the application or computer level by using the
<pages> element in the Web.config or Machine.config file.
<pages buffer="true" …> - 5. Ensure Pages Are Batch Compiled
Here is how to tweak web.config for batch compilation
<compilation
batch="true|false"
batchTimeout="number of seconds"
maxBatchSize="maximum number of pages per batched compilation"
maxBatchGeneratedFileSize="maximum combined size (in KB) of the
generated source file per batched compilation"
</compilation>
- 6. Caching. If application is fetching, transforming, and rendering data that is static or nearly static, we can avoid redundant hits by using caching. And also partial caching of pages can be introduced quickly.