Don't forget to tune your application

Having recently completed a large website implementation for a well respected not-for-profit organisation, I learnt several lessons and want share some of my experiences.

While it seems obvious that we should be ensuring our code is optimised (right? :-/), there are some factors that are "factory-set" and may need to alteration to suit your application and its environment.

Two good resources for you to look at are :-

1) Microsoft's Improving .NET Application Performance and Scalability, especially Chapter 17.

2) Paul Glavich and Chris Farrell's .NET Performance Testing and Optimization - The Complete Guide

An important attribute of tuning that was relevant for this implementation was maxconnection. This particular application made calls to a remote WCF service, and we changed the value from the default (being 2) to an appropriate value. The MS resource recommends that you set it to 12 times the number of CPUs.

The maxconnection attribute can be found on the <ConnectionManagement> element in Machine.config. The default values are as follows.

 <connectionManagement>
  <add address="*" maxconnection="2"/>
</connectionManagement>

I added an extra 'row' for the WCF service ... thus, the config entry become .... (the IP address has been changed to protect the innocent).

 <connectionManagement>
  <add address="127.0.0.1" maxconnection="24"/>   <add address="*" maxconnection="2"/> </connectionManagement>

Other attributes you should consider are :-

  • maxIoThreads. The recommendation is to set maxIoThreads to 100.
  • maxWorkerThreads. The recommendation is to set maxWorkerThreads to 100.
  • minFreeThreads. The recommendation is to set minFreeThreads to 88 * # of CPUs.
  • minLocalRequestFreeThreads. The recommendation is to set minLocalRequestFreeThreads to 76 * # of CPUs.
  • So, the moral of this adventure is not to forget to tune your application for your destination environment. I even recommend having a "tuning champion" in your organisation (or even become the champion yourself!)

    Until the next installment...

    UPDATE:
    A commenter, Md Tariq Ul Azam, mentioned

    <processModel autoConfig="true" />
    


    Now, it is correct that it sets maxIoThreads, maxWorkerThreads, minFreeThreads, minLocalRequestFreeThreads and the maxConnection settings based on the machines' configuration. How it sets these values are detailed here. The processModel element is detailed at MSDN.

    But, I do recommend reading a great article by Omar Al Zabir over at CodeProject called 10 ASP.NET Performance and Scalability Secrets.

    Omar points out, and I agree with him, that you should tweak the values.

    2 Comments

    • Interesting updates.

      Thanks for this write up and Links.

      Will read to be up to speed.

      Regards

      KRK

    • Hi,

      As i understand with ASP.NET 2.0, we have a new configuration section called processModel in machine.config





      the autoConfig="true" (which is by default true) sets maxIoThreads, maxWorkerThreads, maxWorkerThreads, minFreeThreads automatically to its optimized value. If you need anything other than this, then you can use them in web.config.

      Please correct me if i am wrong and thanks for posting this helpful article.

    Comments have been disabled for this content.