SlideShare a Scribd company logo
1 of 25
SUPERCHARGING
PHP pages with mod_lsapi
in CloudLinux OS
Why it was needed?
suPHP / CGI
• slow
• doesn’t support .htaccess
mod_php
• insecure
• requires MPM prefork
mod_fcgid
• hard to keep stable / requires tuning
• sub-optimal caching
• no support for .htaccess
• hard to do multi-versions / customers
FPM
• sub-optimal security due to the way sockets used
• no support for .htaccess
• hard to do multi-versions
• separate pool per customer / sub-optimal memory usage
• Blazing fast
• Outperforms any other Apache PHP handler
• Supports mod_php options format
<Directory /usr/local/www/phpMyAdmin>
php_admin_value open_basedir none
</Directory>
• Full opcode caching
• No tuning required and easy to install
• Supports .htaccess PHP directives
php_value include_path ".:/usr/local/lib/php"
php_flag display_errors Off
php_value upload_max_filesize 2M
• Supports CageFS and PHP selector
o opens possibility of multiple PHP versions per client
• Secure, based on suexec mechanism
• Potential for even better performance
Why mod_lsapi?
OPCODE
CACHE
FULLY SUPPORTS:
 APC
 xCache
 Zend OPcache
Opcode cache uses shared memory, that shares code across requests for end
user. mod_lsapi configured not to reset cache on Apache restarts. Something
impossible to do with mod_php
What is lsphp
lsphp - PHP + LSAPI
What is LSAPI?
LiteSpeed Server Application Programming Interface (LSAPI) is designed
specifically for seamless, optimized communication between LiteSpeed Web Server
and third party web applications. Now this protocol is available for Apache 2.2/2.4.
Using LSAPI, we have seen greater performance than Apache with
mod_php, easy installation than php-fpm, easy integration with
control panel. LSAPI means faster, more stable dynamic web pages.
- apache passes handling for PHP request
to mod_lsapi
- mod_lsapi uses liblsapi to transfers
request lsphp daemon
- lsphp processes request and returns data
to mod_lsapi.
- If no lsphp processes available when new
request comes, new lsphp process created.
HOW IT WORKS
VH2
VH1
HTTPD - root (1)
HTTPD - nobody
- request (2)
HTTPD - nobody
- request (2)
HTTPD - nobody
- request (2)
child of HTTPD
nobody - lsphp
starter (3)
lsphp - user1
(4)
lsphp - user2
(4)
1. apache module handle requests (2) -
mod_lsapi.so;
2. starter daemon - starts lsphp on
demand (3) - from mod_lsapi.so,
child of HTTPD - block (1);
3. lsphp - executes php file and sends
results back to (2) (4) - native lsphp
or lsphp from alt-php)
INSTALLATION1. Install common packages:
yum install liblsapi liblsapi-devel
2. Install mod_lsapi sources and hooks:
yum install mod_lsapi
3. Prepare environment for work
/usr/bin/switch_mod_lsapi --setup
Next steps for cPanel with EasyApache3 only
4. Detect native php version and build correct lsphp binary file:
/usr/bin/switch_mod_lsapi --build-native-lsphp
5. Enable mod_lsapi:
/usr/bin/switch_mod_lsapi --enable-global
6. Restart apache:
service httpd restart
INSTALLATION
EasyApache 4
1. Install common packages:
yum install liblsapi liblsapi-devel
2. Install mod_lsapi package:
wget http://repo.cloudlinux.com/cloudlinux/sources/cloudlinux_ea3_to_ea4
sh cloudlinux_ea3_to_ea4 --convert --mod_lsapi
3. Prepare environment for work (creating directory with correct rights
for socket and make native lsphp as php 5.6 version):
/usr/bin/switch_mod_lsapi –setup
4. Enable mod_lsapi:
/usr/bin/switch_mod_lsapi --enable-global
5. Restart apache:
service httpd restart
DirectAdmin custombuild has full support of
mod_lsapi. lsphp native builds during custombuild
rebuilding process.
1. cd /usr/local/directadmin/custombuild
2. ./build update
3. ./build set php1_release lsphp
4. ./build php n
5. ./build apache
DirectAdmin
INSTALLATION
How to enable mod_lsapi on ISPManager:
1. yum install liblsapi liblsapi-devel --enablerepo=cloudlinux-updates-testing
2. yum install mod_lsapi --enablerepo=cloudlinux-updates-testing
3. /usr/bin/switch_mod_lsapi --setup
4. uncomment string LoadModule lsapi_module modules/mod_lsapi.so from file /etc/httpd/conf.d/mod_lsapi.conf
5. disable php support for needed domain (this action comment out AddHandler or AddType for VirtualHost) or
for all domains.
6. remove from /etc/httpd/conf/httpd.conf strings:
<Directory /var/www/*/data/>
php_admin_flag engine off
</Directory>
or
6. add to needed (where mod_lsapi should be enabled) VirtualHost such strings:
<Directory /var/www/[username]/data/www/[domain]>
Options -ExecCGI -Includes
php_admin_flag engine on
</Directory>
7. uncomment string AddType application/x-httpd-lsphp .php5 .php4 .php .php3 .php2 .phtml in file
/etc/httpd/conf.d/mod_lsapi.conf
8. service httpd restart
ISPManager and mod_lsapi cooperation
/usr/bin/switch_mod_lsapi and control panels
What commands are available for different control panels
No CP cPanel DirectAdmin Plesk InterWorx ISPManager
install + +
+ (no need in
manual calling)
+ + +
uninstall + + - + + +
enable-domain - + - - - -
disable-domain - + - - - -
enable-global - + +/- (custombuild) - - -
disable-global - + - - - -
build-native-lsphp - + +/- (custombuild) - - -
Additional notes about native php installation
*Native php - php installed and used before alt-php packages was installed. lsphp binary usually
not present on server without LiteSpeed and this means that it should be created (build from php
sources with such options as usual php binary file but with LSAPI protocol built-in)
There are two ways to make native lsphp:
1. QUICK - supports all type of panels - native lsphp makes from alt-php56 (switch_mod_lsapi --setup)
cp /opt/alt/php56/usr/bin/lsphp /usr/local/bin/
2. SLOW - detects version of native php and build needed sources according to installed php (cPanel only):
switch_mod_lsapi --build-native-lsphp
! DirectAdmin has own native lsphp builder
/usr/local/directadmin/custombuild/build set php1_release lsphp
/usr/local/directadmin/custombuild/build php n
mod_lsapi as suPHP replacement (cPanel)
mod_lsapi is a drop in replacement for suPHP. No configuration changes need to be
done.
RECOMMENDED PROCEDURE:
1. Install mod_lsapi and call
/usr/bin/switch_mod_lsapi --setup
2. Switch individual domain to check how it goes:
/usr/bin/switch_mod_lsapi --enable-domain example.com
3. Switch whole server globally so all domains start working on mod_lsapi:
/usr/bin/switch_mod_lsapi --enable-global
Config file location on different servers
All mod_lsapi configuration options are placed in single config file. The file will not be
changed or updated by any package reinstalls, easyapache builds on cPanel or
custombuild on DirectAdmin.
/etc/httpd/conf.d/mod_lsapi.conf
cPanel with EasyApache 3
cPanel with EasyApache 4
DirectAdmin
RPM based
/usr/local/apache/conf/conf.d/lsapi.conf
/etc/apache2/conf.d/mod_lsapi.conf
/etc/httpd/conf/extra/mod_lsapi.conf
 mod_lsapi errors will be located in regular
apache error_log and own sulsphp_log.
 Errors from clients like PHP notices, code
errors are written to error_log file.
 Errors from PHP starter are written to
sulsphp_log file, they are related running
lsphp as service and are mostly helpful in
getting error 500 in browser.
WHERE TO FIND ERRORS
Different PHP versions (without PHP Selector)
mod_lsapi allow to use different handlers for different php versions. For example file with
extension .php53 can be handled by php5.3 and file with extension .php handled by php5.5
without PHP Selector.
This is done seting handlers and php binaries for them in /etc/container/php.handler file
EXAMPLE:
# cat /etc/container/php.handler
application/x-lsphp53 /opt/alt/php53/usr/bin/lsphp
application/x-lsphp55 /opt/alt/php55/usr/bin/lsphp
Default handler for lsphp is - application/x-httpd-lsphp . Setting following options in domain
.htaccess file :
AddType application/x-httpd-lsphp .php .php5 .php4.php3 .php2 .phtml
AddType application/x-lsphp53 .php53
Means that file index.php53 will be processed by php5.3, but index.php processed by native lsphp
Example mod_lsapi configuration
LoadModule lsapi_module modules/mod_lsapi.so
<IfModule lsapi_module>
<FilesMatch ".(php|php4|php5|php53|php54|php55|php56|php6|phtml)$">
AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .phtml
AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .phtml
</FilesMatch>
lsapi_debug Off
lsapi_set_env TEMP "/tmp"
lsapi_set_env TMP "/tmp"
lsapi_set_env TMPDIR "/tmp"
</IfModule>
Most of php file extensions are covered by AddType option. If you wants to use
additional handlers for directory for existing extension, you should remove
conflicting extension from main lsapi.conf file
Useful mod_lsapi directives to tune it up
lsapi_backend_children
# Maximum number of simultaneously running child backend processes.
# How many requests in parallel it can process
# Optional, default value is 120
lsapi_backend_pgrp_max_idle
# How long a control backend process will wait for a new request before it exits, in
sec. Default value is 30
# Decrease to minimize memory usage. Increase to make faster response from sites
# 0 stands for infinite.
lsapi_backend_max_process_time
# The maximum processing time allowed when processing a request, in sec.
# Optional, default value is 300.
Useful mod_lsapi directives to tune it up
lsapi_backend_max_idle
# How long a backend child process will wait for a new request before it exits, in sec
# Optional, default value is 300. 0 stands for infinite.
# Decrease to minimize memory usage
lsapi_backend_max_reqs
# How many requests each child process will handle before it exits automatically.
# Optional, default value is 10000.
More things about mod_lsapi
Q: Is it compatible with EasyApache3/4?
Q: Is it compatible with PHP directives in .htaccess?
Q: I have httpd.conf with SuExecUserGroup options. Do I need to add mod_lsapi related options?
Q: How do I install mod_lsapi on Plesk panel?
Q: Can mod_lsapi work without CageFS?
Q: How many servers are running mod_lsapi now?
FUTURE
IMPROVEMENTS
Connection pool
mod_lsapi tries to use pool of persistent connections to lsphp
processes. Persistent connections to backends significantly increase
module performance. mod_lsapi can keep up to 50 persistent
connections for every socket name. In the case when the number of
connections used at the same time exceeds the maximum, the module
will process the next request in conventional, non-persistent mode.
Random socket name
Mod_lsapi will be use for communication with lsphp socket with
random name
lsphp cold start improvement
Will be added notification mechanism for detection if lsphp was
started
mod_lsapi+criu
Will be added criu support to speed up lsphp startup time
https://criu.org/Main_Page
cPanel Servers
$ /usr/bin/switch_mod_lsapi –uninstall
DirectAdmin servers
$ cd /usr/local/directadmin/custombuild
$ ./build update
$ ./build set php1_release [any other php type]
$ ./build php n
$ ./build apache
RPM:
$ yum erase mod_lsapi
$ rm [path to mod_lsapi.conf]
# restore standard php handler
$ service httpd restart
UNINSTALL
mod_lsapi
Performance tests
TEST SERVER CONFIGURATION:
 Test consists of hitting sites powered by php installed different ways (suphp, itk+mod_php, mod_ruid2 +
mod_php etc).
 Tested site: wordpress (for checking opcache effect), simple script for checking environment effects, more
complex php script for checking environment and opcahce effects.
 Environment effects - fork, connect, poll and other algorithms in php, which can affect response time.
• Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz
• 8Gb memory
• CloudLinux Server release 6.6 (Leonid Kizim)
• php 5.3+no cagefs+no LVE(unlimited)
• apache 2.2
Performance tests (wordpress)
wordpress test opcache (req per second) no opcache (req per second)
suphp 23.86 41.36
mod_fcgid 112.21 5.42
itk 180.49 45.36
php-fpm 277.42 52.71
mod_ruid2 322.14 53.77
mod_lsapi 325.56 54.12
Wordpress test
400
300
200
100
0
opcache
no opcache
Requestspersecond
suphp mod_fcgid itk php-fpm mod_ruid2 mod_lsapi
php type
Questions?
Twitter.com/CloudLinuxOS Visit CloudLinux.com

More Related Content

What's hot

The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 
CMake - Introduction and best practices
CMake - Introduction and best practicesCMake - Introduction and best practices
CMake - Introduction and best practicesDaniel Pfeifer
 
HDFS User Reference
HDFS User ReferenceHDFS User Reference
HDFS User ReferenceBiju Nair
 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelKernel TLV
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nulsMalk Zameth
 
eBPF in the view of a storage developer
eBPF in the view of a storage developereBPF in the view of a storage developer
eBPF in the view of a storage developerRichárd Kovács
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsHisaki Ohara
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
An Introduction to CMake
An Introduction to CMakeAn Introduction to CMake
An Introduction to CMakeICS
 
OFI libfabric Tutorial
OFI libfabric TutorialOFI libfabric Tutorial
OFI libfabric Tutorialdgoodell
 
Bottom half in linux kernel
Bottom half in linux kernelBottom half in linux kernel
Bottom half in linux kernelKrishnaPrasad630
 
Migrating from BIG-IP Deployment to NGINX ADC
Migrating from BIG-IP Deployment to NGINX ADCMigrating from BIG-IP Deployment to NGINX ADC
Migrating from BIG-IP Deployment to NGINX ADCNGINX, Inc.
 

What's hot (20)

The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Introduction to CMake
Introduction to CMakeIntroduction to CMake
Introduction to CMake
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Tc basics
Tc basicsTc basics
Tc basics
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
CMake - Introduction and best practices
CMake - Introduction and best practicesCMake - Introduction and best practices
CMake - Introduction and best practices
 
HDFS User Reference
HDFS User ReferenceHDFS User Reference
HDFS User Reference
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux Kernel
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nuls
 
eBPF in the view of a storage developer
eBPF in the view of a storage developereBPF in the view of a storage developer
eBPF in the view of a storage developer
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructions
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
An Introduction to CMake
An Introduction to CMakeAn Introduction to CMake
An Introduction to CMake
 
OFI libfabric Tutorial
OFI libfabric TutorialOFI libfabric Tutorial
OFI libfabric Tutorial
 
Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0
 
Bottom half in linux kernel
Bottom half in linux kernelBottom half in linux kernel
Bottom half in linux kernel
 
Play with UEFI
Play with UEFIPlay with UEFI
Play with UEFI
 
Migrating from BIG-IP Deployment to NGINX ADC
Migrating from BIG-IP Deployment to NGINX ADCMigrating from BIG-IP Deployment to NGINX ADC
Migrating from BIG-IP Deployment to NGINX ADC
 

Viewers also liked

Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360CloudLinux
 
LVE Manager's New UI
LVE Manager's New UILVE Manager's New UI
LVE Manager's New UICloudLinux
 
How lve stats2 works for you and your customers
How lve stats2 works for you and your customersHow lve stats2 works for you and your customers
How lve stats2 works for you and your customersCloudLinux
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较Ji ZHANG
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3Wataru OKAMOTO
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructuremkherlakian
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMWebscale
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春Ryo Tomidokoro
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An IntroductionJacques Woodcock
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木beyond0iwamoto
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLIJacques Woodcock
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るYoshio Hanawa
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015 Yuta Sakamoto
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係Yoshio Hanawa
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with DockerYosh de Vos
 
Alternative Infrastucture
Alternative InfrastuctureAlternative Infrastucture
Alternative InfrastuctureMarc Seeger
 

Viewers also liked (20)

Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360
 
LVE Manager's New UI
LVE Manager's New UILVE Manager's New UI
LVE Manager's New UI
 
How lve stats2 works for you and your customers
How lve stats2 works for you and your customersHow lve stats2 works for you and your customers
How lve stats2 works for you and your customers
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3
 
From LAMP to LNNP
From LAMP to LNNPFrom LAMP to LNNP
From LAMP to LNNP
 
Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPM
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
 
Alternative Infrastucture
Alternative InfrastuctureAlternative Infrastucture
Alternative Infrastucture
 

Similar to Supercharging your PHP pages with mod_lsapi in CloudLinux OS

Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with NginxBud Siddhisena
 
Information on PHP Handlers
Information on PHP HandlersInformation on PHP Handlers
Information on PHP HandlersHTS Hosting
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stackRootGate
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linuxVicent Selfa
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Chris Tankersley
 
Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Chris Tankersley
 
Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Mandakini Kumari
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Chris Tankersley
 
Professional deployment
Professional deploymentProfessional deployment
Professional deploymentIvelina Dimova
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsyncHazel Smith
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.pptwebhostingguy
 

Similar to Supercharging your PHP pages with mod_lsapi in CloudLinux OS (20)

Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
Information on PHP Handlers
Information on PHP HandlersInformation on PHP Handlers
Information on PHP Handlers
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 
Secure PHP environment
Secure PHP environmentSecure PHP environment
Secure PHP environment
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015
 
Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015
 
Apache
ApacheApache
Apache
 
Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04
 
Performance_Up.ppt
Performance_Up.pptPerformance_Up.ppt
Performance_Up.ppt
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
 
EC CUBE 3.0.x installation guide
EC CUBE 3.0.x installation guideEC CUBE 3.0.x installation guide
EC CUBE 3.0.x installation guide
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Php myadmin
Php myadminPhp myadmin
Php myadmin
 
Sahu
SahuSahu
Sahu
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
 
Apache Cheat Sheet
Apache Cheat SheetApache Cheat Sheet
Apache Cheat Sheet
 
PHP Handlers
PHP HandlersPHP Handlers
PHP Handlers
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

Supercharging your PHP pages with mod_lsapi in CloudLinux OS

  • 1. SUPERCHARGING PHP pages with mod_lsapi in CloudLinux OS
  • 2. Why it was needed? suPHP / CGI • slow • doesn’t support .htaccess mod_php • insecure • requires MPM prefork mod_fcgid • hard to keep stable / requires tuning • sub-optimal caching • no support for .htaccess • hard to do multi-versions / customers FPM • sub-optimal security due to the way sockets used • no support for .htaccess • hard to do multi-versions • separate pool per customer / sub-optimal memory usage
  • 3. • Blazing fast • Outperforms any other Apache PHP handler • Supports mod_php options format <Directory /usr/local/www/phpMyAdmin> php_admin_value open_basedir none </Directory> • Full opcode caching • No tuning required and easy to install • Supports .htaccess PHP directives php_value include_path ".:/usr/local/lib/php" php_flag display_errors Off php_value upload_max_filesize 2M • Supports CageFS and PHP selector o opens possibility of multiple PHP versions per client • Secure, based on suexec mechanism • Potential for even better performance Why mod_lsapi?
  • 4. OPCODE CACHE FULLY SUPPORTS:  APC  xCache  Zend OPcache Opcode cache uses shared memory, that shares code across requests for end user. mod_lsapi configured not to reset cache on Apache restarts. Something impossible to do with mod_php
  • 5. What is lsphp lsphp - PHP + LSAPI What is LSAPI? LiteSpeed Server Application Programming Interface (LSAPI) is designed specifically for seamless, optimized communication between LiteSpeed Web Server and third party web applications. Now this protocol is available for Apache 2.2/2.4. Using LSAPI, we have seen greater performance than Apache with mod_php, easy installation than php-fpm, easy integration with control panel. LSAPI means faster, more stable dynamic web pages.
  • 6. - apache passes handling for PHP request to mod_lsapi - mod_lsapi uses liblsapi to transfers request lsphp daemon - lsphp processes request and returns data to mod_lsapi. - If no lsphp processes available when new request comes, new lsphp process created. HOW IT WORKS VH2 VH1 HTTPD - root (1) HTTPD - nobody - request (2) HTTPD - nobody - request (2) HTTPD - nobody - request (2) child of HTTPD nobody - lsphp starter (3) lsphp - user1 (4) lsphp - user2 (4) 1. apache module handle requests (2) - mod_lsapi.so; 2. starter daemon - starts lsphp on demand (3) - from mod_lsapi.so, child of HTTPD - block (1); 3. lsphp - executes php file and sends results back to (2) (4) - native lsphp or lsphp from alt-php)
  • 7. INSTALLATION1. Install common packages: yum install liblsapi liblsapi-devel 2. Install mod_lsapi sources and hooks: yum install mod_lsapi 3. Prepare environment for work /usr/bin/switch_mod_lsapi --setup Next steps for cPanel with EasyApache3 only 4. Detect native php version and build correct lsphp binary file: /usr/bin/switch_mod_lsapi --build-native-lsphp 5. Enable mod_lsapi: /usr/bin/switch_mod_lsapi --enable-global 6. Restart apache: service httpd restart
  • 8. INSTALLATION EasyApache 4 1. Install common packages: yum install liblsapi liblsapi-devel 2. Install mod_lsapi package: wget http://repo.cloudlinux.com/cloudlinux/sources/cloudlinux_ea3_to_ea4 sh cloudlinux_ea3_to_ea4 --convert --mod_lsapi 3. Prepare environment for work (creating directory with correct rights for socket and make native lsphp as php 5.6 version): /usr/bin/switch_mod_lsapi –setup 4. Enable mod_lsapi: /usr/bin/switch_mod_lsapi --enable-global 5. Restart apache: service httpd restart
  • 9. DirectAdmin custombuild has full support of mod_lsapi. lsphp native builds during custombuild rebuilding process. 1. cd /usr/local/directadmin/custombuild 2. ./build update 3. ./build set php1_release lsphp 4. ./build php n 5. ./build apache DirectAdmin INSTALLATION
  • 10. How to enable mod_lsapi on ISPManager: 1. yum install liblsapi liblsapi-devel --enablerepo=cloudlinux-updates-testing 2. yum install mod_lsapi --enablerepo=cloudlinux-updates-testing 3. /usr/bin/switch_mod_lsapi --setup 4. uncomment string LoadModule lsapi_module modules/mod_lsapi.so from file /etc/httpd/conf.d/mod_lsapi.conf 5. disable php support for needed domain (this action comment out AddHandler or AddType for VirtualHost) or for all domains. 6. remove from /etc/httpd/conf/httpd.conf strings: <Directory /var/www/*/data/> php_admin_flag engine off </Directory> or 6. add to needed (where mod_lsapi should be enabled) VirtualHost such strings: <Directory /var/www/[username]/data/www/[domain]> Options -ExecCGI -Includes php_admin_flag engine on </Directory> 7. uncomment string AddType application/x-httpd-lsphp .php5 .php4 .php .php3 .php2 .phtml in file /etc/httpd/conf.d/mod_lsapi.conf 8. service httpd restart ISPManager and mod_lsapi cooperation
  • 11. /usr/bin/switch_mod_lsapi and control panels What commands are available for different control panels No CP cPanel DirectAdmin Plesk InterWorx ISPManager install + + + (no need in manual calling) + + + uninstall + + - + + + enable-domain - + - - - - disable-domain - + - - - - enable-global - + +/- (custombuild) - - - disable-global - + - - - - build-native-lsphp - + +/- (custombuild) - - -
  • 12. Additional notes about native php installation *Native php - php installed and used before alt-php packages was installed. lsphp binary usually not present on server without LiteSpeed and this means that it should be created (build from php sources with such options as usual php binary file but with LSAPI protocol built-in) There are two ways to make native lsphp: 1. QUICK - supports all type of panels - native lsphp makes from alt-php56 (switch_mod_lsapi --setup) cp /opt/alt/php56/usr/bin/lsphp /usr/local/bin/ 2. SLOW - detects version of native php and build needed sources according to installed php (cPanel only): switch_mod_lsapi --build-native-lsphp ! DirectAdmin has own native lsphp builder /usr/local/directadmin/custombuild/build set php1_release lsphp /usr/local/directadmin/custombuild/build php n
  • 13. mod_lsapi as suPHP replacement (cPanel) mod_lsapi is a drop in replacement for suPHP. No configuration changes need to be done. RECOMMENDED PROCEDURE: 1. Install mod_lsapi and call /usr/bin/switch_mod_lsapi --setup 2. Switch individual domain to check how it goes: /usr/bin/switch_mod_lsapi --enable-domain example.com 3. Switch whole server globally so all domains start working on mod_lsapi: /usr/bin/switch_mod_lsapi --enable-global
  • 14. Config file location on different servers All mod_lsapi configuration options are placed in single config file. The file will not be changed or updated by any package reinstalls, easyapache builds on cPanel or custombuild on DirectAdmin. /etc/httpd/conf.d/mod_lsapi.conf cPanel with EasyApache 3 cPanel with EasyApache 4 DirectAdmin RPM based /usr/local/apache/conf/conf.d/lsapi.conf /etc/apache2/conf.d/mod_lsapi.conf /etc/httpd/conf/extra/mod_lsapi.conf
  • 15.  mod_lsapi errors will be located in regular apache error_log and own sulsphp_log.  Errors from clients like PHP notices, code errors are written to error_log file.  Errors from PHP starter are written to sulsphp_log file, they are related running lsphp as service and are mostly helpful in getting error 500 in browser. WHERE TO FIND ERRORS
  • 16. Different PHP versions (without PHP Selector) mod_lsapi allow to use different handlers for different php versions. For example file with extension .php53 can be handled by php5.3 and file with extension .php handled by php5.5 without PHP Selector. This is done seting handlers and php binaries for them in /etc/container/php.handler file EXAMPLE: # cat /etc/container/php.handler application/x-lsphp53 /opt/alt/php53/usr/bin/lsphp application/x-lsphp55 /opt/alt/php55/usr/bin/lsphp Default handler for lsphp is - application/x-httpd-lsphp . Setting following options in domain .htaccess file : AddType application/x-httpd-lsphp .php .php5 .php4.php3 .php2 .phtml AddType application/x-lsphp53 .php53 Means that file index.php53 will be processed by php5.3, but index.php processed by native lsphp
  • 17. Example mod_lsapi configuration LoadModule lsapi_module modules/mod_lsapi.so <IfModule lsapi_module> <FilesMatch ".(php|php4|php5|php53|php54|php55|php56|php6|phtml)$"> AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .phtml AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .phtml </FilesMatch> lsapi_debug Off lsapi_set_env TEMP "/tmp" lsapi_set_env TMP "/tmp" lsapi_set_env TMPDIR "/tmp" </IfModule> Most of php file extensions are covered by AddType option. If you wants to use additional handlers for directory for existing extension, you should remove conflicting extension from main lsapi.conf file
  • 18. Useful mod_lsapi directives to tune it up lsapi_backend_children # Maximum number of simultaneously running child backend processes. # How many requests in parallel it can process # Optional, default value is 120 lsapi_backend_pgrp_max_idle # How long a control backend process will wait for a new request before it exits, in sec. Default value is 30 # Decrease to minimize memory usage. Increase to make faster response from sites # 0 stands for infinite. lsapi_backend_max_process_time # The maximum processing time allowed when processing a request, in sec. # Optional, default value is 300.
  • 19. Useful mod_lsapi directives to tune it up lsapi_backend_max_idle # How long a backend child process will wait for a new request before it exits, in sec # Optional, default value is 300. 0 stands for infinite. # Decrease to minimize memory usage lsapi_backend_max_reqs # How many requests each child process will handle before it exits automatically. # Optional, default value is 10000.
  • 20. More things about mod_lsapi Q: Is it compatible with EasyApache3/4? Q: Is it compatible with PHP directives in .htaccess? Q: I have httpd.conf with SuExecUserGroup options. Do I need to add mod_lsapi related options? Q: How do I install mod_lsapi on Plesk panel? Q: Can mod_lsapi work without CageFS? Q: How many servers are running mod_lsapi now?
  • 21. FUTURE IMPROVEMENTS Connection pool mod_lsapi tries to use pool of persistent connections to lsphp processes. Persistent connections to backends significantly increase module performance. mod_lsapi can keep up to 50 persistent connections for every socket name. In the case when the number of connections used at the same time exceeds the maximum, the module will process the next request in conventional, non-persistent mode. Random socket name Mod_lsapi will be use for communication with lsphp socket with random name lsphp cold start improvement Will be added notification mechanism for detection if lsphp was started mod_lsapi+criu Will be added criu support to speed up lsphp startup time https://criu.org/Main_Page
  • 22. cPanel Servers $ /usr/bin/switch_mod_lsapi –uninstall DirectAdmin servers $ cd /usr/local/directadmin/custombuild $ ./build update $ ./build set php1_release [any other php type] $ ./build php n $ ./build apache RPM: $ yum erase mod_lsapi $ rm [path to mod_lsapi.conf] # restore standard php handler $ service httpd restart UNINSTALL mod_lsapi
  • 23. Performance tests TEST SERVER CONFIGURATION:  Test consists of hitting sites powered by php installed different ways (suphp, itk+mod_php, mod_ruid2 + mod_php etc).  Tested site: wordpress (for checking opcache effect), simple script for checking environment effects, more complex php script for checking environment and opcahce effects.  Environment effects - fork, connect, poll and other algorithms in php, which can affect response time. • Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz • 8Gb memory • CloudLinux Server release 6.6 (Leonid Kizim) • php 5.3+no cagefs+no LVE(unlimited) • apache 2.2
  • 24. Performance tests (wordpress) wordpress test opcache (req per second) no opcache (req per second) suphp 23.86 41.36 mod_fcgid 112.21 5.42 itk 180.49 45.36 php-fpm 277.42 52.71 mod_ruid2 322.14 53.77 mod_lsapi 325.56 54.12 Wordpress test 400 300 200 100 0 opcache no opcache Requestspersecond suphp mod_fcgid itk php-fpm mod_ruid2 mod_lsapi php type