1

I'm trying to understand the timeout value in apache since I want to make my server run very fast. On my local server, I tried using an apache timeout of 5 seconds. I then attempted to execute the following PHP code as an actual script.

<?php
    echo "EXEC...";
    sleep(12);
    echo "EXEC OK";
    echo time();
?>

As expected it took time to load, but the script finished after 12 seconds as instructed in the script code, however the apache timeout is 5 seconds. This doesn't make sense.

So then I thought if the timeout value didn't stop my script from executing completely, then I should be able to get away with setting the timeout to maybe even 3 seconds at most considering the connection time to my site is well under one second. I think I can safely assume that 99.9% of the people requesting my site will be able to have it completely loaded in one second.

Is there anything I should watch out for before setting the timeout value to a couple seconds?

1

From http://httpd.apache.org/docs/2.0/mod/core.html#timeout

The Apache timeout directive defines the amount of time Apache will wait to receive a get request, or the amount of time between receipt of the TCP packets on PUT and POST requests, the time between receipt of ACK's on the transmission of TCP packets in response.

Put another way using your test you never hit the limit as the even though you put a sleep in place in the code TCP packets where still being sent and received between the server and the browser.

As an example the default timeout setting for Apache is 300 seconds and this is more than ample for most configurations.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.