php-fpm 相关

 ps aux | grep -c php-fpm

查看php-fpm进程数:
ps aux | grep -c php-fpm

查看运行内存
/usr/bin/php  -i|grep mem

重启php-fpm
/etc/init.d/php-fpm restart

 

pm = dynamic ; The number of child processes to be created when pm is set to 'static' and the; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.; This value sets the limit on the number of simultaneous requests that will be; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP; CGI. The below defaults are based on a server without much resources. Don't; forget to tweak pm.* to fit your needs.; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'; Note: This value is mandatory.pm.max_children = 5 ; The number of child processes created on startup.; Note: Used only when pm is set to 'dynamic'; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2pm.start_servers = 2 ; The desired minimum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.min_spare_servers = 1 ; The desired maximum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.max_spare_servers = 3 ; The number of seconds after which an idle process will be killed.; Note: Used only when pm is set to 'ondemand'; Default Value: 10s;pm.process_idle_timeout = 10s; ; The number of requests each child process should execute before respawning.; This can be useful to work around memory leaks in 3rd party libraries. For; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.; Default Value: 0;pm.max_requests = 500

php-fpm优化参数介绍
他们分别是:pm、pm.max_children、pm.start_servers、pm.min_spare_servers、pm.max_spare_servers。

pm:表示使用那种方式,有两个值可以选择,就是static(静态)或者dynamic(动态)。
在更老一些的版本中,dynamic被称作apache-like。这个要注意看配置文件的说明。


下面4个参数的意思分别为:

pm.max_children:静态方式下开启的php-fpm进程数量
pm.start_servers:动态方式下的起始php-fpm进程数量
pm.min_spare_servers:动态方式下的最小php-fpm进程数
pm.max_spare_servers:动态方式下的最大php-fpm进程数量

区别:

如果dm设置为 static,那么其实只有pm.max_children这个参数生效。系统会开启设置数量的php-fpm进程。
如果dm设置为 dynamic,那么pm.max_children参数失效,后面3个参数生效。
系统会在php-fpm运行开始 的时候启动pm.start_servers个php-fpm进程,
然后根据系统的需求动态在pm.min_spare_servers和pm.max_spare_servers之间调整php-fpm进程数

 

 

 

将值修改为如下:
pm.max_children = 32
pm.start_servers = 16
pm.min_spare_servers = 8
pm.max_spare_servers = 32
pm.max_requests = 500

posted @ 2016-11-03 19:15  笑笑别人  阅读(171)  评论(0编辑  收藏  举报