Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:php:lsapi-environment-variables [2018/09/19 16:08]
Michael Alegre [LSAPI_MAX_IDLE]
litespeed_wiki:php:lsapi-environment-variables [2021/01/31 14:43]
George Wang update LSAPI_MAX_PROCESS_TIME default from 300 to 3600
Line 40: Line 40:
 Setting ''​LSAPI_CHILDREN''​ to ''​1''​ puts LSWS in Worker mode. In Worker mode, LiteSpeed Web Server dynamically spawns new PHP processes to meet demand and kills finished processes. In this mode, an external application'​s Instances setting under **Configuration > External App > your_external_application** should match the **Max Connections** setting in the same location. Setting ''​LSAPI_CHILDREN''​ to ''​1''​ puts LSWS in Worker mode. In Worker mode, LiteSpeed Web Server dynamically spawns new PHP processes to meet demand and kills finished processes. In this mode, an external application'​s Instances setting under **Configuration > External App > your_external_application** should match the **Max Connections** setting in the same location.
  
-Setting ''​LSAPI_CHILDREN''​ to ''​1''​ puts LSWS in ProcessGroup mode. In ProcessGroup mode, the web server will start one constantly-running PHP parent process. This process will then fork child PHP processes (as opposed to spawning new processes) to meet demand. ProcessGroup mode is generally preferred because all PHP processes can then share one memory block for opcode caching. In ProcessGroup mode, **Instances** should be set to ''​1'',​ while ''​LSAPI_CHILDREN''​ should be set to match the value of **Max Connections**.+Setting ''​LSAPI_CHILDREN''​ to ''​a number larger than 1''​ puts LSWS in ProcessGroup mode. In ProcessGroup mode, the web server will start one constantly-running PHP parent process. This process will then fork child PHP processes (as opposed to spawning new processes) to meet demand. ProcessGroup mode is generally preferred because all PHP processes can then share one memory block for opcode caching. In ProcessGroup mode, **Instances** should be set to ''​1'',​ while ''​LSAPI_CHILDREN''​ should be set to match the value of **Max Connections**.
  
 ==== LSAPI_AVOID_FORK ==== ==== LSAPI_AVOID_FORK ====
Line 51: Line 51:
  
 When set to ''​1'',​ the internal process manager will try to avoid frequently stopping and starting child processes. This might be preferred in a dedicated hosting environment because it may be faster to recycle existing processes, even if it means sometimes running unused processes. When set to ''​1'',​ the internal process manager will try to avoid frequently stopping and starting child processes. This might be preferred in a dedicated hosting environment because it may be faster to recycle existing processes, even if it means sometimes running unused processes.
 +
 +However, if your server has less than 1 GB available memory, just setting ''​LSAPI_AVOID_FORK=1''​ will not work, since LSPHP will only keep the child processes if there is enough available memory which by default is set to 1 GB, If your server has less available memory than that, set it with a limit by replacing it with ''​LSAPI_AVOID_FORK=100M''​. This will set a limit for the ''​LSAPI_AVOID_FORK''​ variable and will run as expected.
  
 ==== LSAPI_EXTRA_CHILDREN ==== ==== LSAPI_EXTRA_CHILDREN ====
Line 59: Line 61:
  
 In ProcessGroup mode, the ''​LSAPI_EXTRA_CHILDREN''​ environment variable controls the maximum number of extra child processes that can be started when existing child processes are malfunctioning. The total number of child processes will be reduced to the level set in ''​LSAPI_CHILDREN''​ as soon as service is back to normal. In ProcessGroup mode, the ''​LSAPI_EXTRA_CHILDREN''​ environment variable controls the maximum number of extra child processes that can be started when existing child processes are malfunctioning. The total number of child processes will be reduced to the level set in ''​LSAPI_CHILDREN''​ as soon as service is back to normal.
 +
 ==== LSAPI_MAX_REQS or PHP_LSAPI_MAX_REQUESTS ==== ==== LSAPI_MAX_REQS or PHP_LSAPI_MAX_REQUESTS ====
  
Line 78: Line 81:
  
 In ProcessGroup mode, ''​LSAPI_MAX_IDLE_CHILDREN''​ controls how many idle child processes are allowed. Extra idle child processes will be killed by the parent process immediately. In ProcessGroup mode, ''​LSAPI_MAX_IDLE_CHILDREN''​ controls how many idle child processes are allowed. Extra idle child processes will be killed by the parent process immediately.
-==== extMaxIdleTime ==== 
-**extMaxIdleTime** in LSWS server configuration is the total time that an idle PHP process group (no request is being processed), wait for new request before exiting. the process group will be gone after timeout. 
  
 ==== LSAPI_MAX_PROCESS_TIME ==== ==== LSAPI_MAX_PROCESS_TIME ====
  
-Default Value: ''​300''​ seconds+Default Value: ''​3600''​ seconds
  
 The ''​LSAPI_MAX_PROCESS_TIME''​ environment variable controls the total time that a PHP process can spend processing a request. It is only effective in ProcessGroup or Daemon mode. The parent process will kill child processes spending more time than this threshold. The ''​LSAPI_MAX_PROCESS_TIME''​ environment variable controls the total time that a PHP process can spend processing a request. It is only effective in ProcessGroup or Daemon mode. The parent process will kill child processes spending more time than this threshold.
Line 96: Line 97:
 ==== LSAPI_PPID_NO_CHECK ==== ==== LSAPI_PPID_NO_CHECK ====
  
-By default, an LSAPI external application will exit automatically when the parent process dies. This is to reduce orphan processes when the web server is restarted. However, it may be desirable to disable this feature in certain situations, such as when an LSAPI process was started manually from the command line. Adding the ''​LSAPI_PPID_NO_CHECK''​ environment variable and setting it to ''​1''​ will disable the check for the existence of a parent process. To turn this setting off, remove the environment variable completely. When PHP is started from the command line using the ''​-b''​ option, this check is disabled automatically.+By default, an LSAPI external application will exit automatically when the parent process dies. This is to reduce orphan processes when the web server is restarted. However, it may be desirable to disable this feature in certain situations, such as when an LSAPI process was started manually from the command line. 
 + 
 +Adding the ''​LSAPI_PPID_NO_CHECK''​ environment variable and setting it to ''​1''​ will disable the check for the existence of a parent process. To turn this setting off, remove the environment variable completely. When PHP is started from the command line using the ''​-b''​ option, this check is disabled automatically.
 ==== LSAPI_ALLOW_CORE_DUMP ==== ==== LSAPI_ALLOW_CORE_DUMP ====
  
Line 103: Line 106:
 ==== LSAPI_ACCEPT_NOTIFY ==== ==== LSAPI_ACCEPT_NOTIFY ====
  
-By default, an LSAPI application will send back a notification packet whenever a request has been received. ​Since PHP LSAPI v5.0, it can be changed to only notify the server for newly established connections by setting this environment variable to ''​1''​. ​It is recommended as a way to gain performance in LiteSpeed Web Server ​4.1 and later.+By default, an LSAPI application will send back a notification packet whenever a request has been received. ​As of PHP LSAPI v5.0, it can be changed to only notify the server for newly established connections by setting this environment variable to ''​1''​. ​This is recommended as a way to gain performance in LiteSpeed Web Server ​v4.1 and later.
  
 ==== LSAPI_SLOW_REQ_MSECS ==== ==== LSAPI_SLOW_REQ_MSECS ====
  
 If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server. If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server.
 +
 +==== LSAPI_CLEAN_SHUTDOWN ====
 +Available as of PHP LSAPI v7.6.
 +
 +The ''​LSAPI_CLEAN_SHUTDOWN''​ environment variable can be used to instruct LSPHP to automatically perform a clean shutdown. A clean shutdown refers to performing cleanup after a PHP crash or abnormal exit (such as manually killing the process).
 +
 +Setting ''​LSAPI_CLEAN_SHUTDOWN=0''​ will disable the clean shutdown feature while setting ''​ LSAPI_CLEAN_SHUTDOWN=1''​ will enable it. Clean shutdown is enabled by default for PHP versions 7.0+ and disabled by default for all prior versions.
  • Admin
  • Last modified: 2023/01/31 20:51
  • by Lisa Clarke