Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To control how many requests an IIS FastCGI worker handles before IIS recycles it, change Instance MaxRequests (instanceMaxRequests) on the matching FastCGI application entry. Microsoft documents a default of 200 and an accepted range of 1 to 10,000,000. You can edit the entry in IIS Manager or target it with AppCmd.exe; the executable path and arguments must match the entry used by the site’s handler mapping.

What FastCGI recycling controls

IIS manages FastCGI worker processes for each FastCGI application definition. instanceMaxRequests sets the maximum number of requests each worker process can handle before it is recycled. It is a per-worker request counter, not one shared counter for the whole IIS application pool.

Recycling can limit long-lived process state, including memory growth, but it does not diagnose or repair a leak. A lower threshold also means more process starts and initialization work. Microsoft’s configuration reference lists 200 as the default and 1–10,000,000 as the range for instanceMaxRequests (FastCGI application configuration).

Choose the right FastCGI setting

These settings manage different events. Changing the request threshold will not fix a slow request, an idle process, or a full request queue.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Purpose Documented default and range
instanceMaxRequests (Instance MaxRequests) Recycles each FastCGI worker after it handles the configured number of requests. Default 200; range 1–10,000,000.
idleTimeout (Idle Timeout) Shuts down a FastCGI process after it has remained idle. Default 300 seconds; range 10–604,800 seconds.
activityTimeout (Activity Timeout) Limits how long IIS waits for FastCGI activity, such as communication or data transfer. Default 30 seconds; range 10–3,600 seconds.
requestTimeout (Request Timeout) Limits the time allowed for an individual request. Default 90 seconds; range 10–604,800 seconds.
monitorChangesTo (Monitor Changes to) Restarts the FastCGI application when a specified file changes. No default; available starting with IIS 7.5.
maxInstances (Max Instances) Limits the number of FastCGI worker processes in the process pool. Current schema reference: default 0. Older IIS Manager documentation says 4; verify the effective value on the server.
queueLength (Queue Length) Limits the number of requests queued for the FastCGI process pool; a full queue can result in HTTP 503 responses. Default 1,000; range 1–10,000,000.

These defaults and ranges are from Microsoft’s FastCGI application reference; the version-sensitive Max Instances difference is also described in its older IIS Manager documentation. IIS application-pool recycling is another, separate worker-process mechanism.

Before changing a setting

  • Confirm IIS and its FastCGI component are installed, and that the FastCGI executable exists at the configured path.
  • Use an account with permission to edit the IIS configuration. Back up or export the relevant configuration before a production change.
  • Identify the FastCGI application entry used by the site’s handler mapping. IIS matches the handler’s scriptProcessor to the FastCGI definition’s fullPath and arguments.
  • Decide the configuration scope. /commit:apphost writes to server-level ApplicationHost.config; a server-level definition can affect multiple sites. Lower-level configuration depends on inheritance, section locking, and the IIS configuration model.

For example, a handler value such as C:PHPphp-cgi.exe|-d open_basedir=C:WebsitesWebsite1 identifies an executable and a non-empty argument string. It is a different FastCGI entry from the same executable with empty arguments. Do not assume the example path is universal. See Microsoft’s FastCGI section overview for configuration levels and handler mapping context.

Change Instance MaxRequests in IIS Manager

  1. Open IIS Manager with administrative privileges and select the target server in the Connections pane.
  2. In the server’s Home pane, open FastCGI Settings.
  3. Select the FastCGI application whose executable path and arguments match the site’s handler mapping, then choose Edit in the Actions pane.
  4. Set Instance MaxRequests to the desired per-worker request threshold. Review Idle Timeout, Activity Timeout, Request Timeout, Max Instances, Queue Length, or Monitor Changes to only if those behaviors are part of the issue.
  5. Select OK to save.

The control names and navigation are documented for Windows Server 2012 R2; their placement may vary slightly on newer releases. If the entry does not exist, use Add Application on FastCGI Settings, provide the executable’s full path and any arguments, configure the required environment variables, and ensure a handler mapping points to that same executable and argument string. Adding an application entry alone does not create a working handler mapping for every file type. Microsoft’s IIS Manager guide documents the page and its controls.

Change an existing entry with AppCmd.exe

Run AppCmd from an elevated Command Prompt. The executable is normally at %windir%System32inetsrvAppCmd.exe. First inspect the server’s FastCGI configuration:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
%windir%System32inetsrvAppCmd.exe list config /section:system.webServer/fastCgi /config:*

To inspect configuration at a site, use its site path:

%windir%System32inetsrvAppCmd.exe list config "Default Web Site/" /section:system.webServer/fastCgi /config:*

The /config:* option includes inherited and default values as well as explicit settings. Copy the exact fullPath and arguments values from the output. To set the threshold to 10,000 on an existing entry with empty arguments, run this in Command Prompt:

%windir%System32inetsrvAppCmd.exe set config /section:system.webServer/fastCgi /[fullPath='C:PHPphp-cgi.exe',arguments=''].instanceMaxRequests:10000 /commit:apphost

Replace the sample path, argument string, and threshold with the values appropriate to the target entry. The selector must match both identity fields exactly. The /commit:apphost option commits at server level to ApplicationHost.config; use it when the intended change is a server-level FastCGI definition. AppCmd also supports other commit targets, including site and application configuration, but the section must be allowed at that level. Refer to Microsoft’s AppCmd reference for collection syntax and commit behavior.

Add an entry only when it is absent

This example adds a new collection item with a 10,000-request threshold and other explicit settings:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
%windir%System32inetsrvAppCmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='C:PHPphp-cgi.exe',arguments='',maxInstances='4',idleTimeout='300',activityTimeout='30',requestTimeout='90',instanceMaxRequests='10000',protocol='NamedPipe',flushNamedPipe='False']" /commit:apphost

The /+ syntax adds an item; it does not edit an existing one. Inspect first to avoid a duplicate or duplicate-key error.

Coordinate PHP’s own request limit when applicable

For PHP, Microsoft documents the optional PHP_FCGI_MAX_REQUESTS environment variable. Its value must be less than or equal to IIS’s instanceMaxRequests; it is PHP-specific, not a universal FastCGI requirement. The following adds or configures the variable on the PHP entry shown in the example—adjust the identity to match the actual entry:

%windir%System32inetsrvAppCmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='C:PHPphp-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']" /commit:apphost

See Microsoft’s documentation for the FastCGI environment-variable element and its PHP environment-variable guidance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the effective configuration

  1. Re-run the relevant AppCmd list config command, including /config:* when you need inherited and default values.
  2. Confirm that the selected entry shows the intended instanceMaxRequests, and that its fullPath and arguments match the handler’s scriptProcessor.
  3. Send a test request through the affected site. Check IIS and application logs for configuration errors, HTTP 500 or 503 responses, and process-start failures.
  4. If the change addresses memory growth or stale state, observe the process under a representative workload rather than expecting an immediate visible change.

Multiple workers, concurrent requests, process startup timing, inheritance, and application behavior can make a recycle difficult to observe at an exact request number. Effective configuration is a more reliable first check than trying to infer the threshold from a brief manual test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common problems

FastCGI Settings is missing

Verify that the FastCGI component is installed and that IIS Manager has the required feature set. Confirm that you selected the server level and that the server has the expected IIS role and services.

AppCmd says no matching element exists

The entry may use a different executable path, non-empty arguments, configuration level, or target server. Inspect with list config, then copy the exact fullPath and arguments into the selector. If a handler’s scriptProcessor contains a pipe, the text after it is significant.

The command creates a duplicate

You used /+, which adds a collection item. Inspect existing entries and use a selector-based property assignment to edit an existing entry instead.

AppCmd reports a lock violation

A section locked at server level cannot necessarily be overridden lower in the configuration hierarchy. Prefer a server-level change if central enforcement is intended. AppCmd can unlock a section with the command below, but doing so changes configuration governance and may permit site-level overrides, so do not unlock it merely to bypass the error:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
%windir%System32inetsrvAppCmd.exe unlock config /section:system.webServer/fastCgi

The change appears ineffective

Check whether the request reaches another handler, executable, or argument-specific entry; whether inherited configuration changes the effective value; and whether multiple workers distribute the request load. Also check whether the symptom is actually due to requestTimeout, activityTimeout, queue saturation, IIS application-pool recycling, or a runtime’s own process manager.

Choose a request threshold for the workload

There is no universal best value. Microsoft’s sample uses 10,000 for PHP as an example, not as a performance recommendation for all applications. Base the threshold on observed process behavior and runtime guidance.

  • A lower threshold may suit a runtime with suspected memory growth or accumulating process state, but increases startup and initialization work and can discard in-process caches more often.
  • A higher threshold may reduce process startup frequency when the runtime is stable and warm caches are useful, but allows a leaking or stateful process to remain alive longer.
  • Coordinate the IIS threshold with runtime-specific recycling controls. For PHP, keep PHP_FCGI_MAX_REQUESTS at or below the IIS threshold.
  • Monitor memory, request latency, and process starts under representative traffic, then adjust rather than assuming that a higher value necessarily improves performance.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.