LSWS 4.2 Introduces PHP suEXEC Daemon Mode
LSWS 4.2 release has a great news for shared hosting providers, who can get most advantages of the much expected new feature. This release introduces PHP suEXEC daemon mode, which will improve memory efficiency of PHP processes, as well as overall server performance.
The advantages of PHP suEXEC daemon mode are:
- Reduce PHP startup cost.
In suEXEC daemon mode, new PHP processes are started by using fork() system call , instead of starting a brand new PHP process. Comparing to launching a new process, fork() is much faster, and it can take advantage of copy-on-write virtual memory management by OS kernel.
- Improve Opcode cache efficiency.
Opcode cache memory can only be shared among children processes forked off the same parent process. For standalone PHP processes, each process will allocate its own opcode cache memory, and release it when the process exits. In suEXEC daemon mode, all PHP worker processes are forked off the same parent process running as root, PHP opcode cache memory are shared by all PHP processes, and it won’t be flushed as long as the parent process still running. Since opcode cache can now be shared among all users, with saved memory, you will be able to allocate larger memory block for opcode cache; in return, more compiled PHP scripts and variables can stay in cache with improved cache hit rate.
So, how to take advantage of this new feature?
- The easiest way is to reinstall LSWS 4.2 from scratch in which PHP daemon mode will be enabled by default.
- If you cannot do a fresh reinstall, you can follow the below steps to enable the feature:
- Upgrade to 4.2 first, suEXEC daemon mode is disabled by default.
- Recompile PHP with latest LSAPI 6.0. You can build matching PHP from WHM plugin, or from LSWS web console where LSAPI 6.0 code will be used by default.
- Enable PHP suEXEC daemon mode by updating lsphp5 external application configuration From LSWS web console, change from “Run On Start Up” to “suEXEC daemon”.
- Repeat step 2-3 for each PHP external application if multiple versions of PHP are used.
Note: This feature is not yet supported on Solaris.