IIS Process Recycling

Starting with IIS 6.0, IIS supports two distinct application isolation modes: worker process isolation mode, and IIS 5.0 isolation mode. IIS 5.0 isolation mode mimics an IIS 5.0 or IIS 5.1 server, which allows for in-process, pooled-process, and out-of-process applications. Worker process isolation mode isolates all application code in individual worker processes without a performance penalty. For more information, see IIS Modes of Operation, or see the IIS user documentation.

IIS 5.1 and earlier: Worker process isolation mode, process recycling, and application pools are not available.

Process Recycling

Worker process isolation mode offers process recycling, in which IIS automatically refreshes Web applications by restarting their worker processes. Process recycling keeps problematic applications running smoothly, and is an especially effective solution in cases where it is not possible to modify the application code.

Process recycling, which follows the occurrence of a recycling event, can happen in two ways.

  • If the worker process currently serving the application pool terminates, then the WWW Service (W3SVC), acting as the parent process to the worker processes, restarts a new process in its place.

  • When the worker process terminates, a new one is started simultaneously. This type of recycling is called overlapped recycling. It is the default for all application pools.

Overlapped Recycling

In an overlapped recycling scenario, the process targeted for a recycle continues to process all remaining requests while a replacement worker process is created simultaneously. The new process is started before the old worker process stops, and requests are then directed to the new process. This design prevents delays in service, since the old process continues to accept requests until the new process has initialized successfully, and is instructed to shut down only after the new process is ready to handle requests.

Note

Since the timeout value of an overlapped recycle is configurable, the worker process can potentially be terminated while it is still serving requests if it does not finish draining requests within the time limit.

Considerations When Recycling Applications

When applications are recycled, it is possible for session state to be lost. During an overlapped recycle, the occurrence of multi-instancing is also a possibility.

Loss of session state: Many IIS applications depend on the ability to store state. IIS 6.0 can cause state to be lost if it automatically shuts down a worker process that has timed out due to idle processing, or if it restarts a worker process during recycling.

Occurrence of multi-instancing: In multi-instancing, two or more instances of a process run simultaneously. Depending on how the application pool is configured, it is possible for multiple instances of a worker process to run, each possibly loading and running the same application code. The occurrence of an overlapped recycle is an example of multi-instancing, as is a Web garden in which two or more processes serve the application pool regardless of the recycling settings.

If your application cannot run in a multi-instance environment, you must configure only one worker process for an application pool (which is the default value), and disable the overlapped recycling feature if application pool recycling is being used.