Recipe12.23.Configuring Application Pool Recycling


Recipe 12.23. Configuring Application Pool Recycling

Problem

You want to configure an application pool to recycle (restart its associated worker processes) under certain conditions.

Solution

Using a graphical user interface

To configure an application pool to recycle automatically, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the server node in the console tree and select Application Pools.

  3. Right-click on an application pool and select Properties.

  4. Select the Recycling tab.

  5. Choose one of the different options for recycling (see the Discussion section) and click Apply.

To recycle an application pool manually, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the server node in the console tree and select Application Pools.

  3. Right-click on an application pool and select Recycle.

Using a command-line interface

You can't configure application pool recycling from the command line, but once recycling has been configured, you can make IIS log recycling events in the System event log using the following command:

> cscript %systemroot%\inetpub\adminscripts\adsutil.vbs set w3svc/AppPools/ <AppPoolName>/<EventName> true

Replace <AppPoolName> with the name of your application pool and <EventName> with one of the recycling events listed in Table 12-10.

Table 12-10. System events related to application pool recycling

Event name

Description

Event code

AppPoolRecycleTime

Worker process ID recycled after reaching its elapsed time interval

1074

AppPoolRecycleRequests

Worker process ID recycled after reaching its processing request limit

1075

AppPoolRecycleSchedule

Worker process ID recycled after reaching its scheduled recycle time

1076

AppPoolRecycleMemory

Worker process ID recycled after reaching its virtual memory limit

1077

AppPoolRecycleIsapiUnhealthy

Worker process ID recycled due to an unhealthy ISAPI extension being loaded

1078

AppPoolRecycleOnDemand

All worker processes in the specified pool have been recycled at the request of an administrator

1079

AppPoolRecycleConfigChange

All worker processes in the specified pool have been recycled because the pool's configuration has been changed

1080

AppPoolRecyclePrivateMemory

Worker process ID recycled after reaching its private bytes memory limit

1177


Using VBScript
' This code enables app pool recycling ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" strAppPoolName = "<AppPoolName>" ' ------ END CONFIGURATION ---------     set objAppPool = GetObject("IIS://" & strComputer & "/w3svc/AppPools/" _                            & strAppPoolName) objAppPool.AppPoolRecycleRequests = True  objAppPool.PeriodicRestartRequests = 2000 objAppPool.SetInfo( )     WScript.Echo "App Pool recycling set successfully: " & objAppPool.Name

Discussion

Recycling an application pool restarts any worker processes assigned to the pool. Application pools may be configured to recycle based on different conditions:

  • After an elapsed time interval (the default is 1740 minutes or 29 hours).

  • After an elapsed number of processing requests.

  • At scheduled times each day.

Application pools can also be configured to recycle if they consume too much memory, which is typically used for buggy applications that leak memory.

Using a command-line interface

Table 12-10 lists the different System events that can be logged for application pool recycling.

See Also

MS KB 332088 (How to modify Application Pool Recycling events in IIS 6.0)



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net