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
litespeed_wiki:php:process-mode [2018/09/21 16:17]
Michael Alegre [Additional configurations]
litespeed_wiki:php:process-mode [2018/09/24 18:08] (current)
Michael Alegre [Benefits]
Line 35: Line 35:
 </​code>​ </​code>​
  
-Note the two LiteSpeed-specific directives ''​[[litespeed_wiki:​php:​lsapi-environment-variables#​lsphp_processgroup|LSPHP_ProcessGroup]]''​ and ''​[[litespeed_wiki:​php:​lsapi-environment-variables#​lsphp_workers|LSPHP_Workers]]''​. Apache will not understand these directives and may crash if it encounters outside of by an ''<​IfModule LiteSpeed>''​ block.+Note the two LiteSpeed-specific directives ''​[[litespeed_wiki:​php:​lsapi-environment-variables#​lsphp_processgroup|LSPHP_ProcessGroup]]''​ and ''​[[litespeed_wiki:​php:​lsapi-environment-variables#​lsphp_workers|LSPHP_Workers]]''​. Apache will not understand these directives and may crash if it encounters ​them outside of by an ''<​IfModule LiteSpeed>''​ block.
  
 ==== Configuration tips ==== ==== Configuration tips ====
Line 53: Line 53:
 ==== Special notes for use with cPanel ==== ==== Special notes for use with cPanel ====
  
-  * The ''​ProcessGroup''​ directive ​should be placed ​in an include file to avoid being overwritten during WHM upgrades. When configuring ''​ProcessGroup''​ at the Server level, the directive ​should be placed ​in ''/​usr/​local/​apache/​conf/​includes/​pre_virtualhost_global.conf''​. When configuring ''​ProcessGroup''​ at the Virtual Host level, the directive ​should be placed ​in a [[https://​confluence2.cpanel.net/​display/​EA/​Modify+Virtualhost+Containers+With+Include+Files|Virtual Host level include file]].+  * Place the ''​ProcessGroup''​ directive in an include file to avoid it being overwritten during WHM upgrades. When configuring ''​ProcessGroup''​ at the Server level, ​place the directive in ''/​usr/​local/​apache/​conf/​includes/​pre_virtualhost_global.conf''​. When configuring ''​ProcessGroup''​ at the Virtual Host level, ​place the directive in a [[https://​confluence2.cpanel.net/​display/​EA/​Modify+Virtualhost+Containers+With+Include+Files|Virtual Host level include file]].
   * LiteSpeed Web Server versions 5.2.8 and below will stop all PHP processes when performing a restart. This has the negative effect of resetting the opcode cache. Starting from LSWS 5.3, LSPHP will run in detached mode by default allowing PHP processes to survive LSWS restarts. The LSPHP parent will follow the **[[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|Max Idle Time]]** setting in this case.   * LiteSpeed Web Server versions 5.2.8 and below will stop all PHP processes when performing a restart. This has the negative effect of resetting the opcode cache. Starting from LSWS 5.3, LSPHP will run in detached mode by default allowing PHP processes to survive LSWS restarts. The LSPHP parent will follow the **[[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|Max Idle Time]]** setting in this case.
  
Line 62: Line 62:
 ==== Benefits ==== ==== Benefits ====
   * Daemon mode enjoys reduced overhead and faster process generation by forking child processes instead of creating new processes for each new request from the same user.   * Daemon mode enjoys reduced overhead and faster process generation by forking child processes instead of creating new processes for each new request from the same user.
-  * When running PHP using a suEXEC execution method, Daemon mode will conserve resources by killing parent processes that have been idle too long. This is more efficient than Apache + PHP-FPM where at least one process is always running in each user's pool. In addition to this, many suEXEC implementations start PHP processes as standalone processes ​where each standalone process has its own opcode cache. This leaves only a tiny window to take advantage of that process'​s opcode cache before the process ends. When running in Daemon mode, all PHP processes share the same opcode cache memory. This allows for a larger opcode cache memory block with a far improved cache hit rate due to less frequent flushes.+  * When running PHP using a suEXEC execution method, Daemon mode will conserve resources by killing parent processes that have been idle too long. This is more efficient than Apache + PHP-FPM where at least one process is always running in each user's pool. In addition to this, many suEXEC implementations start PHP processes as standalone processeseach with their own opcode cache. This leaves only a tiny window to take advantage of that process'​s opcode cache before the process ends. When running in Daemon mode, all PHP processes share the same opcode cache memory. This allows for a larger opcode cache memory block with an improved cache hit rate due to less frequent flushes.
  
 ==== Limitations ==== ==== Limitations ====
-  * Daemon mode does not allow the use of custom per-user php.ini files. As a result, LiteSpeed Web Server will automatically switch to [[#​worker_mode|Worker mode]] at the Server level if a custom php.ini file is detected.+  * Daemon mode does not allow the use of custom per-user php.ini files. As a result, LiteSpeed Web Server will automatically switch to [[#​worker_mode|Worker mode]] at the Server level if it detects ​a custom php.ini file.
   * Due to it's incompatibility with custom php.ini files, Daemon mode is not compatible with CloudLinux'​s PHP Selector.   * Due to it's incompatibility with custom php.ini files, Daemon mode is not compatible with CloudLinux'​s PHP Selector.
  
Line 77: Line 77:
 ==== Benefits ==== ==== Benefits ====
   * Worker mode is compatible with custom php.ini files including CloudLinux’s CageFS php.ini files, allowing the use of CloudLinux'​s PHP Selector. ​   * Worker mode is compatible with custom php.ini files including CloudLinux’s CageFS php.ini files, allowing the use of CloudLinux'​s PHP Selector. ​
-  * When running PHP using a suEXEC execution method, ​Worker mode will conserve resources by killing processes that have been idle too long. This is more efficient than Apache + PHP-FPM where at least one process is always running in each user's pool.  ​+  * Worker mode conserves resources by killing idle processes. ​When running PHP using a suEXEC execution method, ​this is more efficient than Apache + PHP-FPM where at least one process is always running in each user's pool.  ​
  
 ==== Limitations ==== ==== Limitations ====
-  * Worker mode will create ​a new PHP process when needed. This results ​in the process'​s opcode cache flushing ​each time the processes exits, making ​Worker mode incompatible with opcode and APCu caching. For this reason, ​it is recommended to only use Worker mode if custom.php files are needed but server resources are too limited for [[#​processgroup_mode|ProcessGroup mode]].+  * Worker mode creates ​a new PHP process when needed, resulting ​in the process'​s opcode cache flushing ​when the processes exits. This makes Worker mode incompatible with opcode and APCu caching. For this reason, ​you should ​only use Worker mode if you need custom php.ini files and server resources are too limited for [[#​processgroup_mode|ProcessGroup mode]].
   * Creating a new processes has more overhead than forking child processes. This may cause Worker mode to be slightly slower than [[#​daemon_mode|Daemon]] or [[#​processgroup_mode|ProcessGroup]] modes. This overhead can be greatly reduced by running in [[#​daemon_mode|Daemon mode]] by setting **Start By Server** to ''​Yes (Through CGI Daemon)''​ or ''​Yes (Through CGI Daemon Async)''​ under **Configuration > External App > your_external_application**.   * Creating a new processes has more overhead than forking child processes. This may cause Worker mode to be slightly slower than [[#​daemon_mode|Daemon]] or [[#​processgroup_mode|ProcessGroup]] modes. This overhead can be greatly reduced by running in [[#​daemon_mode|Daemon mode]] by setting **Start By Server** to ''​Yes (Through CGI Daemon)''​ or ''​Yes (Through CGI Daemon Async)''​ under **Configuration > External App > your_external_application**.
  
 ==== Setup ==== ==== Setup ====
-Worker mode will be used when none the setting requirements for [[#​processgroup_mode|ProcessGroup mode]] (default) or [[#​daemon_mode|Daemon mode]] have been met. LiteSpeed Web Server may also automatically switch to Worker mode at the Server level if a custom php.ini file is detected when running in [[#​daemon_mode|Daemon mode]].+LiteSpeed Web Server will use Worker mode when none of the setting requirements for [[#​processgroup_mode|ProcessGroup mode]] (default) or [[#​daemon_mode|Daemon mode]] have been met. LiteSpeed Web Server may also automatically switch to Worker mode at the Server level if it detects ​a custom php.ini file while running in [[#​daemon_mode|Daemon mode]].
  
 ===== Mode Comparison ===== ===== Mode Comparison =====
Line 92: Line 92:
 ^ Number of parent processes ​                       |  One for each process group\\ (each user)  |  1  |  0  | ^ Number of parent processes ​                       |  One for each process group\\ (each user)  |  1  |  0  |
 ^ Customize number of processes per account? |  Yes  |  Yes  |  Yes  | ^ Customize number of processes per account? |  Yes  |  Yes  |  Yes  |
-^ Can be enabled ​only for certain virtual hosts? |  Yes  |  No  |  No  |+^ Can enable ​only for certain virtual hosts? |  Yes  |  No  |  No  |
 ^ Custom php.ini supported? (Including CageFS custom php.ini) |  Yes  |  No  |  Yes  | ^ Custom php.ini supported? (Including CageFS custom php.ini) |  Yes  |  No  |  Yes  |
 ^ Opcode caching |  Dedicated per user  |  Shared throughout server ​ |  No  | ^ Opcode caching |  Dedicated per user  |  Shared throughout server ​ |  No  |
  
  • Admin
  • Last modified: 2018/09/21 16:17
  • by Michael Alegre