Enabling CPU Monitoring in IIS 6.0

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

The CPU monitoring feature monitors and automatically shuts down worker processes that consume large amounts of CPU time. CPU monitoring is enabled for individual application pools.

Before enabling CPU monitoring, take note of the following:

  • IIS must be operating in Worker Worker Process Isolation Mode.

  • CPU monitoring is available only for application pools.

  • CPU monitoring does not apply to CGI applications.

Important

You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /user:Administrative_AccountName "mmc %systemroot%\system32\inetsrv\iis.msc".

Enabling CPU Monitoring by Using IIS Manager

When you enable CPU monitoring by using IIS Manager, IIS allows, by default, a maximum CPU use of 50 percent. To change the default value, follow this procedure.

To enable CPU monitoring

  1. In IIS Manager, expand the local computer, expand the Application Pools folder, right-click the application pool for which you want to enable CPU accounting, and click Properties.

  2. Click the Performance tab, and select the Enable CPU monitoring check box.

  3. In the Maximum CPU use box, click the up and down arrows to set the maximum percentage of the CPU the application pool should use. If the application pool uses more than the designated maximum, IIS generates an error in the Windows Events log.

  4. In the Refresh CPU usage numbers (in minutes) box, click the up and down arrows to set the refresh rate.

  5. In the Action performed when CPU usage exceeds maximum CPU use list box, click the appropriate action for the designated application pool.

    • To have IIS write an event to the system log when the application pool reaches the maximum CPU usage, without shutting the application pool down, click No Action.

    • To shut down the application pool in addition to logging an event in the system log, click Shutdown.

      By default, No Action is selected.

      Important

      Shutting down the application pool shuts down all worker processes that serve that application pool.

  6. Click Apply, and then click OK.

Enabling CPU Monitoring from the Command Line

Enabling CPU monitoring from the command line can take as many as three steps:

  • Set the CPULimit metabase property, which limits the worker processes in a specified application pool to a percentage of CPU time.

  • Set the CPUResetInterval metabase property, which specifies the time interval for CPU monitoring.

  • Set the CPUAction metabase property, which specifies the type of action you want IIS to take, such as write to the event log or shut down worker processes that exceed the CPU limit.

Set the CPU Limit

TheCPULimitproperty configures the maximum percentage of CPU time that the worker processes in an application pool are allowed to consume over the period of time set by the CPUResetInterval property. If the limit set by the CPULimit property is exceeded, an event is written to the event log and an optional set of events can be triggered as determined by the CPUAction property. Setting the value of the CPULimit property to zero disables CPU monitoring.

To start CPU monitoring for an application pool, set the CPULimit property to a value greater than zero. To calculate the value to set, determine the maximum percentage of CPU time that you want the worker processes in an application pool to use — for example, 50 percent (which is the default value). Next multiply that percentage by 1,000 (50  1,000 = 50,000). Hence, to limit CPU use to 50 percent, set a value of 50000 for the CPU limit.

To set the CPU limit for CPU monitoring by using Adsutil.vbs

  1. In the Run dialog box, type cmd, and then click OK.

  2. At the command prompt, type:

    cscript %Systemroot%\Inetpub\AdminScripts\adsutil.vbs set W3SVC/AppPools/ApplicationPoolName/CPULimit n

    Replace n with the maximum percentage of CPU use to allow for the application pool in 1/1,000ths of a percentage.

Set the CPU Reset Interval

After turning on CPU monitoring for the application, use Adsutil.vbs to set a value for the CPUResetInterval property, which specifies the reset period (in minutes) for CPU monitoring and throttling limits on the application pool. When the number of minutes elapsed since the last CPU monitoring reset equals the number specified by this property, IIS resets the CPU timers for both the logging and limit intervals. The default value is five minutes. Setting the value of this property to zero disables CPU monitoring.

Important

The value of the CpuResetInterval property must be greater than the time between logging operations; otherwise, IIS resets counters before logging has occurred, and CPU monitoring does not occur.

To set the CPU monitoring reset interval by using Adsutil.vbs

  1. In the Run dialog box, type cmd, and then click OK.

  2. At the command prompt, type:

    cscript %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs set W3SVC/AppPools/ApplicationPoolName/CPUResetInterval n

    Replace n with the number of minutes for the reset interval. To disable CPU monitoring, type 0.

Set the CPU Action

Finally, set the CPUAction property, which configures the actions that IIS takes when Microsoft® Windows NT® job objects run. Only one Windows NT job object exists per application pool; therefore, you must configure the CPUAction property separately for each application pool. If you do not set the CPUAction metabase property, IIS assigns the default value, which is zero (event logging only).

To set the CPUAction value by using Adsutil.vbs

  1. In the Run dialog box, type cmd, and then click OK.

  2. At a command prompt, type:

    cscript %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs set W3SVC/AppPools/ApplicationPoolName/CPUAction ActionValue

    Replace ActionValue with the appropriate value: 0 logs an error without shutting down the process; 1 logs an error and shuts down the process.

For more information about setting the CPU action, see the CPULimit Metabase Property, the CPUResetInterval Metabase Property, and theCPUAction Metabase Property.

  • For more information about CPU Monitoring, including explanations of the corresponding metabase properties and options for advanced CPU monitoring with Windows System Resource Manager, see Enabling CPU Monitoring.

  • For information about related features that help manage and conserve resources when IIS is running in Worker Process Isolation Mode, see Managing Resources in Worker Process Isolation Mode.