Set IBM i Apache Timeout to a shorter time to recover from lock ups faster

Follow

Issue

Some errors can cause a lock up in an Apache child process.  Apache has a feature to allow such locked processes to be eventually abandoned and replaced.  If the error situation is something Apache can detect, this will allow Apache to reset itself after a reasonable period of time.

To avoid Apache cancelling PHP programs before they complete, Zend Server for IBM i ships with an Apache configuration that sets the timeout to a very long time.  If a customer has some error condition that causes the Apache processes to lock up, over time they may all become locked.  This causes a condition where Apache seems to "freeze up" and requires a restart of Apache to clear the condition.  By setting the Apache timeout to a shorter time, it may be possible to clear the individual lock ups before enough of them occur to completely freeze Apache.  This article tells how to do it.

Environment

Zend Server for IBM i version 5 through 8, running on any supported version of IBM i.

Resolution

The ZENDSVR6 (or ZENDSVR for version 5) instance of APACHE has a timeout of 30000 seconds (500 minutes), so Apache timeouts do not affect long running scripts. However, as long as the Apache timeout does not prevent long running scripts from completing, it should be safe to set it to a less conservative value. In this example, we are setting it to 300 seconds (5 minutes, the IBM default for this value).

Please verify this is not shorter than the PHP timeouts you have set. In the Zend Server Admin interface, you can see the default PHP max_execution_time on the Server Info tab. This can be reset for individual scripts, so also check with the developer of your PHP application to find out if any scripts are set with longer max_execution_time values. If you need to set the Apache timeout for more than 300 seconds, just make the appropriate adjustment to the example, replacing ‘300’ with whatever you need.

Here is how to make the change:

Edit file /www/zendsvr6/conf/httpd.conf (or /www/zendsvr/conf/httpd.conf for version 5). ALWAYS make a back up of this file before making any changes.

Find these lines:

DirectoryIndex index.php index.html
TimeOut 30000
KeepAlive Off
HotBackup Off

Change the TimeOut to 300:

DirectoryIndex index.php index.html 
TimeOut 300
KeepAlive Off
HotBackup Off

Save the change, and then restart the ZENDSVR6 (or ZENDSVR for version 5) instance of Apache.

Have more questions? Submit a request

Comments

Powered by Zendesk