Apache version 2+ doubles the TimeOut directive on requests

tun31n asked:

We have been testing Apache 2+ versions and on all requests the TimeOut directive set is processed 2 times for a request. You can see the log below (TimeOut set to 2 seconds):

[Wed Feb 12 18:04:20 2014] [warn] [client] Timeout waiting for output from CGI script /usr/local/cpanel/cgi-sys/php5
[Wed Feb 12 18:04:20 2014] [error] [client] Script timed out before returning headers: php5
[Wed Feb 12 18:04:22 2014] [warn] [client] Timeout waiting for output from CGI script /usr/local/cpanel/cgi-sys/php5
[Wed Feb 12 18:04:22 2014] [error] [client] File does not exist: /home/davetest/public_html/504.shtml

Apache logs that the request reaches TimeOut set and then allows another 2 seconds interval before returning an error.

The same happens with TimeOut 3 , 5 , 10 etc. – doubles the timeout.

Can you point me to what I am obviously missing here.

EDIT: The php script being executed is simply 60 seconds sleep.

strace output:


System Info:

OS: CentOS 6.5


My answer:

Apache isn’t doing anything wrong: You have two timeouts because you called PHP twice.

The first time was your attempt to load the web page itself, which timed out.

The second time was Apache’s attempt to load the ErrorDocument which, because it doesn’t exist, was passed to PHP for processing.

To resolve the issue, set ErrorDocument to a static HTML page that exists.

ErrorDocument 504 /failwhale.html

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.