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.

    Published Wednesday, June 30, 2010 11:06 AM by johnbilliris
    Filed under: , , , ,

    Comments

    # Don't forget to tune your application - John Billiris

    Tuesday, June 29, 2010 9:43 PM by Don't forget to tune your application - John Billiris

    Pingback from  Don't forget to tune your application - John Billiris

    # re: Don't forget to tune your application

    Tuesday, June 29, 2010 10:14 PM by Raghuraman

    Interesting updates.

    Thanks for this write up and Links.

    Will read to be up to speed.

    Regards

    KRK

    # re: Don't forget to tune your application

    Tuesday, June 29, 2010 11:14 PM by Md Tariq Ul Azam

    Hi,

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

    <system.web>

       <processModel autoConfig="true" />

    </system.web>

    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.

    # re: Don't forget to tune your application

    Saturday, September 10, 2011 7:44 AM by Luke Puplett

    ** Later information regarding .NET 3.5 can be found here **

    blogs.msdn.com/.../asp-net-thread-usage-on-iis-7-0-and-6-0.aspx

    Leave a Comment

    (required) 
    (required) 
    (optional)
    (required)