This is an old revision of the document!


Controlling PHP Max Concurrency

The PHP Max Connection setting is controlled by different configurations depending upon whether or not you're using PHP SuEXEC mode.

If the PHP suEXEC setting (LSWS Admin Console → Server → General → Using Apache Configuration File → PHP suEXEC) is set to “Yes” or “User's Home Directory Only”, then you are using SuEXEC, otherwise you are not using SuEXEC.

When PHP SuEXEC is used, PHP SuEXEC Max Conn will be used to control the PHP Max Concurrency. LiteSpeed Web Server has a number of PHP setups which offer different ways to control the amount of PHP tasks that can be processed at once in PHP SuEXEC mode.

If PHP SuEXEC mode is not used, the External Application LSAPI Max Connections setting will control the PHP Max Concurrency.

This wiki will go over the ways to control concurrency with different PHP LSAPI setups.

PHP suEXEC Max Connections

LSWS offers three different PHP suEXEC modes: Worker, Daemon, and ProcessGroup.

In suEXEC PHP, LSWS allows you to control the number of PHP processes per user.

  1. Worker: Concurrency is controlled by the PHP suEXEC Max Conn setting (WebAdmin > Configuration > Server > General > PHP suEXEC Max Conn). This controls the number of PHP processes allowed per user.
  2. Daemon: Same as above. Concurrency is controlled by the PHP suEXEC Max Conn setting (WebAdmin > Configuration > Server > General > PHP suEXEC Max Conn). This controls the number of PHP processes allowed per user.
  3. ProcessGroup: The PHP suEXEC Max Conn setting sets the default concurrency setting.

PHP suEXEC Max Connections can be customized/overridden at vhost/account level with the “LSPHP_Workers” directive in an Apache configuration file for all three modes:worker, Daemon and ProcessGroup mode.

For example, “40” has been set through PHP suEXEC Max Conn setting in web admin console, but you would like to set a little higher as “100” for a particular user/account, add the following to the user/account's Apache vhost configuration to override the above setting:

<IfModule LiteSpeed>
  LSPHP_Workers 100
</IfModule>

PHP Non-suEXEC Max Connections

LSWS offers two non-suEXEC PHP modes: Worker and ProcessGroup.

In non-suEXEC modes, there is only one PHP user. PHP concurrency is thus controlled by the the number of connections allowed between LSWS and the PHP engine: the External Application Max Connections setting (WebAdmin > Configuration > Server > External App > your external application).

One must make sure that your external application is also supplied with enough processes to serve these connections. The number of processes should always be set to be equal the Max Connections. This is set differently depending on your PHP mode:

  1. Worker: Simply set the Instances setting (WebAdmin > Configuration > Server > External App > your external application).
  2. ProcessGroup: In ProcessGroup, the Instances setting must be set to 1. Control the number of processes instead with the PHP_LSAPI_CHILDREN environment variable.

Which setup am I using?

Some users may be confused about which setup they are using. Follow the steps in the Which PHP setup am I using? wiki to figure it out.

Reached max children process limit?

You might have already fine-tuned the environment variables such as LSAPI_CHILDREN to 50 but still experienced error message like “Reached max children process limit: 15, extra: 5, current: 20, please increase LSAPI_CHILDREN”. <env>LSAPI_CHILDREN=50</env> has been double-checked in lsphp5 external app and seems no problem. Why doesn't match? What happened? How to fix it?

In PHP suEXEC ProcessGroup mode, “increase LSAPI_CHILDREN” means increase PHP SuEXEC Max Conn setting, not “LSAPI_CHILDREN” setting in php external app setting. Please be aware that it is a global setting applied to all virtual hosts hence you may want to increase PHP processes for only one virtual host Increasing LSPHP_Workers can increase the limit, such as explained in this wiki:

<IfModule LiteSpeed>
LSPHP_Workers 100
</IfModule>

Another environment variable can be used to control the total limit, LSAPI_EXTRA_CHILDREN, which is set to “5” for lsphp5 external app. It won't be overridden. So you will get total limit of 15 + 5 = 20.

Increasing “LSAPI_CHILDREN” will allow more foreground PHP processes running. Increase “LSAPI_EXTRA_CHILDREN” will allow more background PHP processes running.

More details configuration can be found: https://www.litespeedtech.com/docs/litespeed-sapi/php-lsapi/configuration

  • Admin
  • Last modified: 2018/09/10 18:58
  • by Jackson Zhang