PHP LiteSpeed Server API suEXEC Daemon Mode https://www.litespeedtech.com/images/logos/litespeed/litespeed-logo.png 2019-08-16 20:56:17 suEXEC Daemon mode keeps all the security of suEXEC, but improves performance by forking new processes from a constantly running parent process as opposed to creating completely new processes.

PHP LSAPI Daemon Mode

PHP LSAPI 6.0 introduced one of LSAPI's most important advances — Daemon mode. Daemon mode allows for faster and more efficient PHP processing in shared hosting environments.

What is suEXEC?

suEXEC is an execution method that makes PHP more secure by running each PHP process as the owner of a particular account instead of the user running the web server. This means that even if one user on a server is compromised, PHP scripts run from their account will not have access to other users' files. suEXEC has long been a basic feature of shared hosting and is completely supported by all LiteSpeed PHP process modes.

What is Daemon mode?

Daemon mode improves performance by forking new PHP processes from a constantly running parent process as opposed to creating completely new processes every time.

Benefits

Faster process generation

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.

Effective opcode caching

In addition to this, many suEXEC implementations start PHP processes as standalone processes, each 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.


Comparison to other setups

  • Apache/nGinx (suPHP) vs. LSPHP

    suPHP is the standard suEXEC setup for Apache.

    • All LiteSpeed process modes (Worker, Daemon, and ProcessGroup) are far faster than suPHP because suPHP uses CGI which is much, much slower than LiteSpeed's LSAPI.
    • suPHP creates a new standalone process for each PHP process. As explained above, creating these new processes requires more overhead, is time-consuming, and prevents the effective use of opcode cache.
  • Apache/nGinx (PHP_FPM) vs. Daemon mode

    PHP-FPM allows Apache and other web servers to make use of FastCGI with PHP.

    • FastCGI is speedier than CGI, but, our benchmarks show, LSAPI is still about 20% faster than FCGI.
    • To get security similar to suEXEC from PHP-FPM, you have to manually set up pools of processes for each user.
    • Each of these pools always leave at least one process running, meaning wasted system resources even when a particular user's sites are inactive. This is especially a problem for servers with many users and thus many pools.
    • When running PHP using a suEXEC execution method, Daemon mode processes are automatically set up to run as the site owner. Daemon mode will also conserve resources by killing parent processes that have been idle too long.
    • Daemon mode makes great use of opcode caching and spawns processes dynamically, using resources only when and where you need them.
  • Other PHP process modes

    Consult our guide to different LiteSpeed PHP Process Modes

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 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.


Configuration

Learn more about configuring Daemon mode in our wiki.