Managing CPU utilization for IIS worker processes that use FastCGI module

Since there have been several questions in the IIS FastCGI forums regarding using IIS CPU Limits feature together with FastCGI, I wanted to talk a little more about how what you should do if you are trying to control CPU while running PHP on IIS7.

First off, It is not possible to use FastCGI when CPU limits feature is turned on. This is because CPU limits feature uses Job Object to manage CPU utilization by worker process, and FastCGI also uses Job Object to ensure that child FastCGI processes are killed when parent worker process is terminated. Since a process can belong to only one Job Object, FastCGI module returns the 500 error if it determines that Job Object is already being used. This behavior is by design.

Even though you can't use the IIS CPU limits feature, you can still control CPU utilization by IIS worker processes. The recommended approach is to use Windows Server Resource Manager (WSRM). WSRM is part of the Windows Server 2008 and it can be used to manage server processor and memory usage with standard or custom resource policies. It is pretty nifty. Refer to this article to get instructions on how to install and configure WSRM for IIS. Note that WSRM documentation article states that WSRM does now work with processes that use Job Objects. This statement is not exactly correct - WSRM cannot manage the processes within Job Object, only if Job Object sets limits that conflict with WSRM (such as memory utilization, process priority, etc). Since Job Object in FastCGI handler does not set any of those limits, WSRM is able to manage FastCGI processes successfully. The WSRM team is going to revise the documentation text to point that out. We wanted to give you a heads up on that detail now so that you could take advantage of WSRM today if you needed it for hosting ASP.NET, PHP or other Fast-CGI compliant applications on IIS7.


No Comments