php-fpm优化小结

WBOY
Release: 2016-06-13 12:17:07
Original
1110 people have browsed it

php-fpm优化总结

环境:php5.6.1

1.如何启用?
编译安装时加上--enable-fpm
2.如何优化?
优化之前根据业务需求规划,然后必须做压力测试;
优化的主要文件就是php-fpm.conf

(1)进程数设置

 pm = dynamic

 pm.max_children = 15

 pm.start_servers = 5

 pm.min_spare_servers = 5

 pm.max_spare_servers = 15

(2)最大处理请求数

最大处理请求数是指一个php-fpm的worker进程在处理多少个请求后就终止掉,master进程会重新respawn新的。

该配置可以避免php解释器自身或程序引起的memory leaks。

默认值是500,

pm.max_requests = 1024


这样的规划,1秒钟

最大请求数:15*1024=15360

最小请求数:5*1024=7120

3.如何避免程序hang死?
在负载较高的服务器上定时重载php-fpm
reload可以平滑重启而不影响生产系统的php脚本运行
每15分钟reload一次
0-59/15 * * * * /usr/local/php/sbin/php-fpm reload

本文只讨论了php-fpm的优化

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!