Share via


FastCGI Error - MaxRequests Settings - Error 0x80004005

Question

Wednesday, December 12, 2007 8:38 AM

When configuring FastCGI (fastcgid) in an Apache + PHP environment the recommendation is to set MaxRequestsPerInstance to 500. This is because php in CGI internally shuts down after 500 requests. More info can be found at the very bottom of this page:

http://fastcgi.coremail.cn/doc.htm

I have lately been receing the following error on a heavily loaded IIS 6.0, Windows 2003 + FastCGI + PHP 5.2.5 w/ Eaccelerator server. The error isn't constant, but happens often enough to certainly be a concern and my users are noticing.

 FastCGI Error
The FastCGI Handler was unable to process the request.

Error Details:

* The FastCGI process exited unexpectedly
* Error Number: -2147467259 (0x80004005).
* Error Description: Unspecified error

HTTP Error 500 - Server Error.
Internet Information Services (IIS)

I am curious if anyone believes these two things could be related. Could this be the 501st request that is failing as is sometimes seen in Apache w/ FastCGI and PHP? Should the iis fastcgi ini file be edited to have a MaxRequestsPerInstance of under 500? Or is there some other reason?

Any tips on debugging this?

 Thanks in advance,

Stephen

 

All replies (10)

Wednesday, December 12, 2007 2:02 PM âś…Answered

 Hi Stephen,

fcgiext.ini changes should happen immediately without recycles/restarts. You can confirm the environment variable is magically picked up using the following experiment:

1) set PHP_FCGI_MAX_REQUESTS=1000 in fcgiext.ini

2) get /hello.php

3) look at php-cgi.exe environment vars using process explorer from sysinternals.com

4) change PHP_FCGI_MAX_REQUESTS=1001 in fcgiext.ini

5) look at php-cgi.exe environment vars using process explorer from sysinternals.com

expected: step 3 sees 1000, step 5 sees 1001

Cheerz,

Rick.


Wednesday, December 12, 2007 11:19 AM

I'll let one of the IIS guys confirm, but I would say it is unlikely. I'd say the 500 request ceiling is a limitation of that particular implementation of FastCGI. To trace the error I would start by taking a look at your IIS log files. Strip out the 500 errors and see if a pattern emerges.

 


Wednesday, December 12, 2007 12:36 PM

Hi Stephen,

There are many reasons for this error, I've tried to cover all the ones I've seen here:

http://blogs.iis.net/rickjames/archive/2007/10/16/fastcgi-debugging-quot-the-fastcgi-process-exited-unexpectedly-quot.aspx

As you mention, one of the reasons for this error is if:

1) the FastCGI process (e.g. php-cgi.exe) exits after N requests AND

2) InstanceMaxRequests > N AND

3) You have lots of load (i.e. requests are queueing while waiting for FastCGI processes to become available)

This is why our setup guide (http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/PHP/Using-FastCGI-to-Host-PHP-Applications-on-IIS-6-0-?Page=2) recommends setting InstanceMaxRequests and PHP_FCGI_MAX_REQUESTS equal to the same value.

Cheerz,

Rick.


Wednesday, December 12, 2007 12:55 PM

/slaps_forehead 

I appreciate the quick response. I modified InstanceMaxRequest to be below 500 and the problem seems to have stopped, so it appears that I totally overlooked that whole line:

Note that you can configure InstanceMaxRequests and PHP_FCGI_MAX_REQUESTS to use numbers other than 10000. As a general rule though you always should make sure that the value of InstanceMaxRequests is less or equal to the value of PHP_FCGI_MAX_REQUESTS

Duh, and this is excatly what we used to do in Apache via similar means. I'll start cranking them back up in tandem till we get a comfortable medium.

On a related note, do the PHP environment vairables get picked up and applied form the .ini file without an App Pool Recycle or IIS reset?

 -Stephen


Wednesday, September 10, 2008 7:16 PM

I am also getting this "Unspecified error (0x80004005)" error randomly throughout the day with IIS7.

I have verified that PHP_FCGI_MAX_REQUESTS = 1000 is set.

 <fastCgi>
            <application fullPath="C:\Program Files\PHP\php-cgi.exe" activityTimeout="60" requestTimeout="90" instanceMaxRequests="10000">
                <environmentVariables>
                    <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
                </environmentVariables>
            </application>
        </fastCgi>

 

The failed request log has an event error "FASTCGI_ACTIVITY_TIMEOUT". Is this just what happens when a script exceeds the FastCGI ActivityTimeout setting?

What are the optimal settings for the activityTimeout and requestTimeout?


Wednesday, April 29, 2009 4:35 AM

 i have the same problem as StephenJII explained , the error is the same , i follow the suggustions you all provided i found the file fcgiext.ini i opend it i found

 ; InstanceMaxRequests=n

changed it to 

 InstanceMaxRequests=500

 

but i couldn't find  PHP_FCGI_MAX_REQUESTS in the file , this problem seems to show up many times within a min when i refresh the browser

please help

 

thank you


Wednesday, April 29, 2009 4:48 AM

PHP_FCGI_MAX_REQUESTS should be set as an environment variable, not a specific fcgiext.ini directive in itself. E.g, in fcgiext.ini add the following under your PHP settings

 EnvironmentVars=PHP_FCGI_MAX_REQUESTS:501

In a nutshell InstanceMaxRequests should have a lesser value than PHP_FCGI_MAX_REQUESTS so that FastCGI controls the PHP process recycling rather than the the PHP process itself.


Wednesday, April 29, 2009 5:27 AM

PHP_FCGI_MAX_REQUESTS should be set as an environment variable, not a specific fcgiext.ini directive in itself. E.g, in fcgiext.ini add the following under your PHP settings

 EnvironmentVars=PHP_FCGI_MAX_REQUESTS:501

In a nutshell InstanceMaxRequests should have a lesser value than PHP_FCGI_MAX_REQUESTS so that FastCGI controls the PHP process recycling rather than the the PHP process itself.

 

thank you so much for your fast response

i went a head and added the line at the bottom of the fcgiext.ini file , right after this 

[Plesk_php5]
ExePath=C:\Parallels\Plesk\Additional\PleskPHP5\php-cgi.exe
[Plesk_php]
ExePath=C:\Parallels\Plesk\Additional\Php\php.exe
EnvironmentVars=PHP_FCGI_MAX_REQUESTS:501

i restart even i read above no need to do it , the iis webserver still doing the same 


Wednesday, April 29, 2009 6:05 AM

 i noticed PHP-CGI process keeps multiplying untill i run out of memory , seems the process does not recycle ? i am trying with this problem all night long lol please help


Saturday, May 2, 2009 4:29 AM

 i took the fast cgi dll from the iis for the websites in my server and now running with php5 dll until i fugure this out , the fastcgi 32 bit installer did not fix it either , i just dont understnd why the process keeps building up in the task manager without turning off the one that are done thier job ,