503 Errors with PHP, Reproducible Easily - question relating to LSAPI_AVOID_FORK

#1
Hi,

I've been running LiteSpeed (standard edition) for several years now and periodically have had issues with 503 errors. These problems have not often been easily reproducible, and didn't occur that often, so I haven't investigated much.

However, recently I set up a new system and installed phpMyAdmin. I was able to very easily reproduce 503 errors by just logging in to phpMyAdmin and changing the theme back and forth from one theme to the other. When I start doing this, every time, within about 10 attempts, usually less, I get a 503 error.

I tried PHP 5.3.8, 5.3.6, 5.2.17, 5.2.10, 5.2.11 all with the exact same results.

Then I looked at the configuration for another server of mine that I had many 503 issues with in the past with vBulletin.

The setting LSAPI_AVOID_FORK comes into question.

For the phpMyAdmin reproducible test, with LSAPI_AVOID_FORK=0 (the default), I can cause 503 errors as I said, easily and reproducible.

With LSAPI_AVOID_FORK=1, I cannot cause a 503 error in the same manner.

For the vBulletin server, if I have LSAPI_AVOID_FORK=0, I end up with 50-100 503 errors in the logs per day (out of many, many requests), and with LSAPI_AVOID_FORK=1 I end up with about 5-10 per day.

So it seems that LSAPI_AVOID_FORK=0 is causing me problems, but I wonder if there is something else that would be causing this as I haven't found much documentation on LSAPI_AVOID_FORK with regards to 503 errors.

My environment settings for the external app are:

PHP_LSAPI_MAX_REQUESTS=100
PHP_LSAPI_CHILDREN=8
LSAPI_AVOID_FORK=1

So my question is why does LSAPI_AVOID_FORK reduce the frequency of 503 errors significantly/almost get rid of them completely? And are there any other settings I should be using instead?
 

webizen

Well-Known Member
#3
it is likely frequent start/stop children lsphp process causing 503 error.

http://litespeedtech.com/php-litespeed-sapi.html
LSAPI_AVOID_FORK specifies the policy of the internal process manager in "Self Managed Mode". When set to 0, the internal process manager will stop and start children process on demand to save system resource. This is preferred in a shared hosting environment. When set to 1, the internal process manager will try to avoid freqently stopping and starting children process. This might be preferred in a dedicate hosting environment.
You should try stock settings to lower 503 count.
PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35
Make sure MaxConnections match with PHP_LSAPI_CHILDREN=35

Also look at the error.log to see any context about 503 errors and figure out the cause of it.
 
Last edited:
#4
it is likely frequent start/stop children lsphp process causing 503 error.

http://litespeedtech.com/php-litespeed-sapi.html


You should try stock settings to lower 503 count.


Make sure MaxConnections match with PHP_LSAPI_CHILDREN=35

Also look at the error.log to see any context about 503 errors and figure out the cause of it.
The thing is, I'm able to reproduce it as described with just phpMyAdmin and no one else hitting the server at all. I've been monitoring the processes and there are only 3 active, and they don't time out, yet I still get a 503. It's never reaching the '100' count of max requests nor is it reaching the max number of children.

On the active server running vBulletin, I'm using

PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35
LSAPI_AVOID_FORK=1

Same situation. I set LSAPI_AVOID_FORK=0 yesterday and got a whole lot of 503 errors, and this morning returned the setting to =1, then saw almost all of the 503 errors disappear. Only have had 1 in the last 6 hours instead of yesterday when I had about 55 in total during 24 hours.

So I don't think it's related to that.

What is the potential fix in 4.1.9 upcoming?

I can provide the reproducible instructions for replicating the issue with phpMyAdmin or provide you access to a virtual server to see and experiment with the issue.
 

webizen

Well-Known Member
#5
frequent php stop/start (LSAPI_AVOID_FORK=0) could cause more 503 errors as server fail to get result back from php process (killed). 4.1.9 (not yet released) addresses the issue of php child process gets killed before it completes the request and should eliminate the problem completely.

you may give 4.1.9 a try (replace 4.1.8 with 4.1.9 in the download link).
 
#6
frequent php stop/start (LSAPI_AVOID_FORK=0) could cause more 503 errors as server fail to get result back from php process (killed). 4.1.9 (not yet released) addresses the issue of php child process gets killed before it completes the request and should eliminate the problem completely.

you may give 4.1.9 a try (replace 4.1.8 with 4.1.9 in the download link).
Glad to hear, I will try 4.1.9 to test it out.
 
Top