Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We're using PHP and Apache, hosted on a dedicated server running Debian Linux. The specific versions in each case are mostly immaterial, as this problem has been around since Debian 6, and is still present in Debian 7; in the meantime we've been using the latest versions of all packages.

We're having problems with PHP script timeouts, which although rare, are behaving erratically and causing severe problems when they do occur.

The timeouts are always recorded in the Apache log, and sometimes the script and everything else may execute/terminate correctly, but often, various failures may be observed, such as:

  • timeouts not registered back to PHP - the script may not terminate as expected (the function registered with register_shutdown_function() - see code example below - may not be called);

  • after a timeout, Apache may run in the background indefinitely, using up CPU resources in one core;

  • Apache may fail altogether - no further requests serviced - Apache must be restarted.

The exact cause of the fault has not been found. It is reproducible on all servers we deploy to.

Example PHP script:

//...
function _on_shutdown()
{
    if (connection_status() & CONNECTION_TIMEOUT)
    {
        echo 'ERROR: TIMEOUT!';
        //Do something else...
    }
    exit;
}
register_shutdown_function('_on_shutdown');
//...more code here...
//(various potentially long running scripts which may timeout)
share|improve this question
    
Are you using APC? –  Michael Hampton Sep 27 '13 at 5:23
    
No, not using APC. –  Ric-at-metaseller.com Sep 27 '13 at 6:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.