PHP-FPM Optimization Summary
Environment: php5.6.1
1. How do I enable it?
Add--ENABLE-FPM when compiling the installation
2. How to optimize?
Before optimization according to business requirements planning, then must do stress testing;
The main document for optimization is php-fpm.conf
(1) Number of processes set
PM = dynamic
Pm.max_children = 15
Pm.start_servers = 5
Pm.min_spare_servers = 5
Pm.max_spare_servers = 15
(2) Maximum number of processing requests
The maximum number of processing requests is when a PHP-FPM worker process terminates after processing the number of requests, and the master process re-respawn the new one.
This configuration avoids memory leaks caused by the PHP interpreter itself or the program.
The default value is 500,
Pm.max_requests = 1024
Such a plan, 1 seconds
Maximum number of requests: 15*1024=15360
Minimum number of requests: 5*1024=7120
3. How to avoid the program hang dead?
Periodically reload PHP-FPM on a server with high load
Reload can smooth restart without affecting the production system PHP script run
Reload once every 15 minutes
0-59/15 * * * */USR/LOCAL/PHP/SBIN/PHP-FPM Reload
This article only discusses the optimization of PHP-FPM