Intensive PHP script failing w/ “The timeout specified has expired” error / ap_content_length_filter

后端 未结 10 1138
南方客
南方客 2020-12-30 10:50

Running a MySQL intensive PHP script that is failing. Apache log reports this:

[Wed Jan 13 00:20:10 2010] [error] [client xxx.xx.xxx.xxxx] (70007)
The timeou         


        
相关标签:
10条回答
  • 2020-12-30 11:31

    for anyone that may come across this. I was able to solve this by looking into memcache.

    my situation:

    1. a memcached server that is being used by multiple apache servers
    2. memcached.sess_locking = On
    3. make back to back requests on the same session (within ms of each other)

    outcome: the second requests gets stucks and times out

    solution 1: set memcached.sess_locking = Off in your php.ini

    Solution 2: decrease memcached.sess_lock_wait_min

    why it works: when a second request comes in while first one has locked the session file, the second session has to wait. If memcached.sess_lock_wait_min is set too high it just waits that long before trying to get the possession of the lock. it is super easy to test this using sess_locking = Off. If it does help you then you definitely want to play around with lock time values to see what works better for you.

    0 讨论(0)
  • 2020-12-30 11:37

    There is a timeout in the php.ini as well.

    0 讨论(0)
  • 2020-12-30 11:42

    I hit a very similar wall as well with Apache 2.4.6 and PHP 5.4.23 FPM/FastCGI.

    Symptom:

    No matter what I set in PHP or Apache, my script would timeout in 30 seconds and I would see the following in my Apache Error log:

    [timestamp] [proxy_fcgi:error] [pid...] (70007)The timeout specified has expired: [client ...] AH01075: Error dispatching request to :

    My VirtualHost:

    TimeOut  300
    KeepAliveTimeout 300
    
    <IfModule reqtimeout_module>
      RequestReadTimeout header=120-240,minrate=500
      RequestReadTimeout body=120,minrate=500
    </IfModule>
    
    <IfModule mod_proxy.c>
      ProxyTimeout 300
    </IfModule>
    
    <IfModule mod_fcgid.c>
      FcgidConnectTimeout 300
    </IfModule>
    

    The pesky php script:

    ini_set( 'max_execution_time', '120' );
    ...
    ini_restore( 'max_execution_time' );
    

    The Fix: it's a hard coded value in Apache mod_proxy_fcgi

    Take a look at the bug report here

    • A patch is available (link above)
    • The fix doesn't appear to be slated for general release yet (Mar 2014)
    0 讨论(0)
  • 2020-12-30 11:45

    There is another timeout value placed not in php itself but in apache server. It will brake script when nothing is on output for specified time so when doing harder work in PHP you can reach this limit. Just echo anything back to browser (not buffers!) or increase apache timeout value to safe value, as far as I remember it's KeepAliveTimeOut apache property. Good luck :)

    0 讨论(0)
提交回复
热议问题