因?yàn)橹鞍l(fā)生502了,日志提示
創(chuàng)新互聯(lián)公司是創(chuàng)新、創(chuàng)意、研發(fā)型一體的綜合型網(wǎng)站建設(shè)公司,自成立以來(lái)公司不斷探索創(chuàng)新,始終堅(jiān)持為客戶提供滿意周到的服務(wù),在本地打下了良好的口碑,在過(guò)去的10多年時(shí)間我們累計(jì)服務(wù)了上千家以及全國(guó)政企客戶,如成都發(fā)電機(jī)回收等企業(yè)單位,完善的項(xiàng)目管理流程,嚴(yán)格把控項(xiàng)目進(jìn)度與質(zhì)量監(jiān)控加上過(guò)硬的技術(shù)實(shí)力獲得客戶的一致稱譽(yù)。
[27-May-2015 13:54:34] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 16 idle, and 602 total children
然后我就自己隨意增加了pm.start_servers參數(shù),一段時(shí)間后,php日志/usr/local/php/var/log/php-fpm.log部分信息如下:
[27-May-2015 15:13:48] NOTICE: [pool www] child 3998 started
[27-May-2015 15:13:59] NOTICE: [pool www] child 9242 exited with code 0 after 47575.960999 seconds from start
[27-May-2015 15:13:59] NOTICE: [pool www] child 4210 started
[27-May-2015 15:14:42] NOTICE: [pool www] child 9217 exited with code 0 after 47619.884065 seconds from start
[27-May-2015 15:14:42] NOTICE: [pool www] child 5621 started
[27-May-2015 15:14:43] NOTICE: [pool www] child 9561 exited with code 0 after 47620.024499 seconds from start
原因就是沒(méi)有pm.start_servers這個(gè)參數(shù)沒(méi)有按照下面的這個(gè)公式來(lái):
pm.start_servers= min_spare_servers + (max_spare_servers - min_spare_servers) / 2
一般min_spare_servers設(shè)置為20
max_spare_servers是根據(jù)服務(wù)器本身的內(nèi)存來(lái)計(jì)算的,標(biāo)準(zhǔn)算法就是內(nèi)存大小除以30M
當(dāng)然,有的php程序可能占用比較小,不到30M,這就看情況來(lái)計(jì)算了。
我設(shè)置的是這樣的
過(guò)濾注釋部分:
cat /usr/local/php/etc/php-fpm.conf | grep -v "^;" | grep -v "^$"
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
rlimit_files = 65535
events.mechanism = epoll
[www]
user = www
group = www
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 1400
pm.start_servers = 710
pm.min_spare_servers = 20
pm.max_spare_servers = 1400
pm.max_requests = 10000
slowlog = log/$pool.log.slow
然后重新加載下
/usr/local/nginx/sbin/nginx -s reload
之后幾天日志沒(méi)有出現(xiàn)信息了。