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 ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.