关于php配置参数
2014-11-05 16:10
155 查看
没事查看了一下php日志,发现提示进程数不够,日志信息如下:
[04-Nov-2014 14:19:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 15 total children[04-Nov-2014 14:29:27] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 16 total children[04-Nov-2014 16:51:04] NOTICE: Finishing ...[04-Nov-2014 16:51:04] NOTICE: exiting, bye-bye![04-Nov-2014 16:51:06] NOTICE: fpm is running, pid 31023[04-Nov-2014 16:51:06] NOTICE: ready to handle connections[04-Nov-2014 19:01:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[04-Nov-2014 19:54:47] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[04-Nov-2014 20:36:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 19 total children[04-Nov-2014 21:18:56] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[05-Nov-2014 05:30:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 15 total children[05-Nov-2014 11:01:37] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[05-Nov-2014 11:01:38] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 21 total children
使用下面的命令查看php进程:[root@test ~]# ps -ef |grep phproot 25874 20907 0 11:56 pts/0 00:00:00 more index.phpwww 26030 31023 32 12:02 ? 00:00:26 php-fpm: pool www www 26037 31023 31 12:02 ? 00:00:22 php-fpm: pool www www 26042 31023 31 12:02 ? 00:00:20 php-fpm: pool www www 26046 31023 30 12:02 ? 00:00:17 php-fpm: pool www www 26054 31023 30 12:02 ? 00:00:15 php-fpm: pool www www 26059 31023 30 12:02 ? 00:00:14 php-fpm: pool www www 26062 31023 30 12:03 ? 00:00:12 php-fpm: pool www www 26063 31023 30 12:03 ? 00:00:09 php-fpm: pool www www 26066 31023 30 12:03 ? 00:00:09 php-fpm: pool www www 26089 31023 23 12:03 ? 00:00:02 php-fpm: pool www www 26092 31023 24 12:03 ? 00:00:01 php-fpm: pool www root 26097 25911 0 12:03 pts/1 00:00:00 grep phproot 31023 1 0 Nov04 ? 00:00:09 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)
内存占用情况:只用了2G左右的内存[root@test etc]# free -m total used free shared buffers cachedMem: 19990 19685 304 0 256 16949-/+ buffers/cache: 2480 17509Swap: 19999 112 19887
打开配置文件php-fpm.conf发现:pm.max_children = 5
修改成如下参数后,发现php日志中无此报警了:
; Note: This value is mandatory.
pm.max_children = 1024
; 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) / 2
pm.start_servers = 512
; 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 = 4
; 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 = 512
查看php-fpm的子进程数,跟配置文件里面设置的一样,等于pm.start_servers+pm.min_spare_servers
[root@test etc]# ps -ef |grep php |wc -l
515
修改php配置文件后,内存占用从2G变成了6.8G左右,增长了4.8G左右,一个php进程开销占到了8M左右,这个可以根据实际的内存情况来进行修改。
[root@localhost log]# free -m
total used free shared buffers cached
Mem: 19990 19438 551 0 189 12414
-/+ buffers/cache: 6835 13154
Swap: 19999 129 19870
补充:
php-fpm有一个参数 max_requests,该参数指明了,每个children最多处理多少个请求后便会被关闭,默认的设置是500。因为php是把请求轮询给每个children,在大流量下,每个childre到达max_requests所用的时间都差不多,这样就造成所有的children基本上在同一时间被关闭,这样会导致此时nginx发给php的请求无法得到相应,会出现短时间的502.解决方法:
增加children的数量,并且将 max_requests 设置未 0 或者一个比较大的值
一般增加max_requests到102400,可能有效果。
[04-Nov-2014 14:19:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 15 total children[04-Nov-2014 14:29:27] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 16 total children[04-Nov-2014 16:51:04] NOTICE: Finishing ...[04-Nov-2014 16:51:04] NOTICE: exiting, bye-bye![04-Nov-2014 16:51:06] NOTICE: fpm is running, pid 31023[04-Nov-2014 16:51:06] NOTICE: ready to handle connections[04-Nov-2014 19:01:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[04-Nov-2014 19:54:47] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[04-Nov-2014 20:36:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 19 total children[04-Nov-2014 21:18:56] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[05-Nov-2014 05:30:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 15 total children[05-Nov-2014 11:01:37] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 17 total children[05-Nov-2014 11:01:38] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 21 total children
使用下面的命令查看php进程:[root@test ~]# ps -ef |grep phproot 25874 20907 0 11:56 pts/0 00:00:00 more index.phpwww 26030 31023 32 12:02 ? 00:00:26 php-fpm: pool www www 26037 31023 31 12:02 ? 00:00:22 php-fpm: pool www www 26042 31023 31 12:02 ? 00:00:20 php-fpm: pool www www 26046 31023 30 12:02 ? 00:00:17 php-fpm: pool www www 26054 31023 30 12:02 ? 00:00:15 php-fpm: pool www www 26059 31023 30 12:02 ? 00:00:14 php-fpm: pool www www 26062 31023 30 12:03 ? 00:00:12 php-fpm: pool www www 26063 31023 30 12:03 ? 00:00:09 php-fpm: pool www www 26066 31023 30 12:03 ? 00:00:09 php-fpm: pool www www 26089 31023 23 12:03 ? 00:00:02 php-fpm: pool www www 26092 31023 24 12:03 ? 00:00:01 php-fpm: pool www root 26097 25911 0 12:03 pts/1 00:00:00 grep phproot 31023 1 0 Nov04 ? 00:00:09 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)
内存占用情况:只用了2G左右的内存[root@test etc]# free -m total used free shared buffers cachedMem: 19990 19685 304 0 256 16949-/+ buffers/cache: 2480 17509Swap: 19999 112 19887
打开配置文件php-fpm.conf发现:pm.max_children = 5
修改成如下参数后,发现php日志中无此报警了:
; Note: This value is mandatory.
pm.max_children = 1024
; 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) / 2
pm.start_servers = 512
; 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 = 4
; 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 = 512
查看php-fpm的子进程数,跟配置文件里面设置的一样,等于pm.start_servers+pm.min_spare_servers
[root@test etc]# ps -ef |grep php |wc -l
515
修改php配置文件后,内存占用从2G变成了6.8G左右,增长了4.8G左右,一个php进程开销占到了8M左右,这个可以根据实际的内存情况来进行修改。
[root@localhost log]# free -m
total used free shared buffers cached
Mem: 19990 19438 551 0 189 12414
-/+ buffers/cache: 6835 13154
Swap: 19999 129 19870
补充:
php-fpm有一个参数 max_requests,该参数指明了,每个children最多处理多少个请求后便会被关闭,默认的设置是500。因为php是把请求轮询给每个children,在大流量下,每个childre到达max_requests所用的时间都差不多,这样就造成所有的children基本上在同一时间被关闭,这样会导致此时nginx发给php的请求无法得到相应,会出现短时间的502.解决方法:
增加children的数量,并且将 max_requests 设置未 0 或者一个比较大的值
一般增加max_requests到102400,可能有效果。
相关文章推荐
- FIS--关于下载php后的配置(启动fis的调试服务器(注意添加 --no-rewrite 参数),如果报错 没有php-cgi环境,请 安装 它,并把php-cgi命令加到系统的环境变量)
- 关于PHP配置之memory_limit参数的设定
- 关于php的register_globals和magic_quotes_gpc参数配置
- Php ini_set ini_get可操作配置参数列表
- 关于fckEditor的功能配置-PHP版
- 关于ssh 配置文件的参数说明
- 编译php的配置参数
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- wxzh001,进来看关于APACHE+PHP+MYSQL+SSL的LINUX下安装配置(转自奥索)
- solr 关于 carrot2聚类参数配置测试
- 关于ssh 配置文件的参数说明
- failed to open stream解决办法-关于WIN主机下配置PHP的若干问题解决方案总结
- 编译php的配置参数
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- PHP环境配置参数
- 关于VLAN配置的几个参数的简单介绍
- PHP学习之路-关于phpmyadmin的配置
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 转贴 关于用 framebuffer 驱动,在console 模式下的分辨率的参数及配置
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto