Apache 2.4 and PHP-FPM Timeout resulting from something I can't find

10,016

So, it turns out that it had something to do with the throttle speed. It was so low that the request was timing out. I fixed that by changing the RequestReadTimeout:

RequestReadTimeout header=20-120,MinRate=50 body=20,MinRate=50

Note this is also helpful if traffic from users is going through a proxy or firewall before getting to your server. The time between the request and the data could be significant.

Share:
10,016

Related videos on Youtube

TurnipEntropy
Author by

TurnipEntropy

Functional programming and Scala enthusiast, MapR and Spark developer, Linux convert, and LAMP stack, Java (WildFly), and JavaScript web developer

Updated on September 18, 2022

Comments

  • TurnipEntropy
    TurnipEntropy almost 2 years

    So I'm looking to find the reason I keep getting timeouts on my Apache 2.4 server with PHP-FPM. Here's the error:

    [proxy_fcgi:error] [pid ###] (70007)The timeout 
    specified has expired:[client XXXXXXXX] AH01075 : 
    Error dispatching request to:, referer: http://address
    

    In the following config files, I have played with every timeout I show. I have two pools in fpm:

    [www]
    ;user and group info and listening ip and such up here
    access_log = /path/to/access.log
    request_terminate_timeout = 15
    php_admin_value[error_log] = /path/to/error.log
    php_admin_flag[log_errors] = on
    

    and the second:

    [app]
    ;user and group info and listening ip and such up here
    access_log = /path/to/access.log
    request_terminate_timeout = 300
    php_admin_value[error_log] = /path/to/error.log
    php_admin_flag[log_errors] = on
    

    and my php.ini:

    max_execution_time = 300
    max_input_time = 300
    default_socket_timeout = 300
    

    So then my Apache config:

    Timeout 80 
    <FilesMatch "^(some | names | of | files)\.php$">
        SetHandler "proxy:fcgi://123.45.5.67:7891"
    </FilesMatch>
    
    <FilesMatch "^!(some | names | of | files)\.php$">
        SetHandler "proxy:fcgi://123.45.5.67:5432"
    </FilesMatch>
    

    Obviously there's a lot more in the httpd.conf, but no timeouts are specified (except for an unrelated ProxyPass set to 300 seconds). I have read this thread: https://unix.stackexchange.com/questions/270655/how-to-find-and-edit-apache-timeout, but I've checked our patches with rpm -q --changelog httpd | less, and there's a patch for that bug. The timeouts were also much more chaotic when I only had one pool. Anywhere from 24 seconds to 6.7 minutes (at 5Kb/s throttled upload speed; not a problem with the code, was purposefully testing). For a while it seemed like it was correlated with request_terminate_timeout, but that correlation died.

    Thanks for any help.

  • Nabeel Khan
    Nabeel Khan about 5 years
    how did you figure it out? it worked for me too
  • TurnipEntropy
    TurnipEntropy about 5 years
    @NabeelKhan Many days of reading documentation and a lot of tests. Reducing the values to very short timeouts and using very small files helped me figure out it was a firewall issue.