nginx php fpm 连接数,哪个php5-fpm设置为高并发连接数nginx
請幫我調(diào)整php5-fpm和nginx的配置.
問題是我的php5-fpm日志不斷報(bào)告慢腳本并殺死子線程.
專用服務(wù)器,quad xeon,32Gb Ram. 1個(gè)php應(yīng)用程序/站點(diǎn)運(yùn)行.
Php應(yīng)用程序:Nutshell,搜索引擎,結(jié)果觸發(fā)curl請求.每次搜索的頁面加載時(shí)間通常為2-3秒.
這就是我認(rèn)為正在發(fā)生的事情
我有750個(gè)并發(fā)的PHP用戶執(zhí)行搜索.由于RAM限制,我只能設(shè)置pm.max_children = 400.我假設(shè)每個(gè)用戶50Mb(子線程),所以= 20GB.我假設(shè)每個(gè)用戶= 1個(gè)子線程.因此,pm.max_children不足以覆蓋那些需要3秒鐘進(jìn)行搜索的750個(gè)活躍php用戶.
所以我認(rèn)為我看到用戶排隊(duì),因?yàn)槲铱吹?秒變成4-7秒.由于用戶排隊(duì)我認(rèn)為腳本越來越慢觸發(fā)錯(cuò)誤日志消息而php5-fpm pm會(huì)殺死孩子?
這就是我認(rèn)為正在發(fā)生的事情.我在下面提供了我的錯(cuò)誤日志輸出,nginx,php5-fpm配置.
我真的很感激任何關(guān)于我是否可以調(diào)整我的配置的建議,如果確實(shí)pm.max_children應(yīng)該至少等于你的最大并發(fā)用戶,請記住我的php搜索打開大約3秒鐘.我需要更多內(nèi)存還是其他服務(wù)器?
這是我的記憶,但我只在大約30分鐘前重新啟動(dòng)了nginx
:/var/log# free -m
total used free shared buffers cached
Mem: 32151 26175 5975 0 186 13334
-/+ buffers/cache: 12654 19496
Swap: 32739 5 32734
php5-fpm:www.conf:
進(jìn)程管理器設(shè)置為靜態(tài)
我正在使用靜態(tài),因?yàn)槲艺J(rèn)為所有的孩子都可以立即使用,而不是產(chǎn)生時(shí)間,我只在盒子上運(yùn)行1個(gè)應(yīng)用程序.
;pm = dynamic
pm = static
;pm.max_children = 10
pm.max_children = 400
;pm.start_servers = 4
pm.start_servers = 150
;pm.min_spare_servers = 2
pm.min_spare_servers = 32
;pm.max_spare_servers = 6
pm.max_spare_servers = 64
;pm.max_requests = 500
pm.max_requests = 10000
php5-fpm日志中的錯(cuò)誤
我應(yīng)該澄清,我在高負(fù)載下看到的行為,一次有750個(gè)用戶是緩存的搜索結(jié)果而不是緩存開始需要更長的時(shí)間.即>緩存為1秒,非緩存為4到7秒.因此,當(dāng)用戶排隊(duì)等待時(shí),我認(rèn)為搜索時(shí)間會(huì)增加,并且它會(huì)在負(fù)載下緩慢運(yùn)行到腳本運(yùn)行緩慢的程度.觸發(fā)通知,孩子被殺.
例如剛剛重啟之后
[04-Jun-2013 20:11:07] NOTICE: Finishing ...
[04-Jun-2013 20:11:11] NOTICE: exiting, bye-bye!
[04-Jun-2013 20:11:12] NOTICE: fpm is running, pid 17899
[04-Jun-2013 20:11:12] NOTICE: ready to handle connections
[04-Jun-2013 20:27:28] WARNING: [pool www] child 18200, script '/home/site/public_html/index.php' (request: "POST /index.php") executing too slow (10.827363 sec), logging
[04-Jun-2013 20:27:28] WARNING: [pool www] child 18138, script '/home/site/public_html/index.php' (request: "POST /index.php") executing too slow (10.827034 sec), logging
[04-Jun-2013 20:27:28] NOTICE: child 18138 stopped for tracing
[04-Jun-2013 20:27:28] NOTICE: about to trace 18138
[04-Jun-2013 20:27:28] NOTICE: finished trace of 18138
[04-Jun-2013 20:27:28] NOTICE: child 18200 stopped for tracing
[04-Jun-2013 20:27:28] NOTICE: about to trace 18200
[04-Jun-2013 20:27:28] NOTICE: finished trace of 18200
[04-Jun-2013 20:52:52] WARNING: [pool www] child 17948, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (11.724081 sec), logging
[04-Jun-2013 20:52:52] NOTICE: child 17948 stopped for tracing
[04-Jun-2013 20:52:52] NOTICE: about to trace 17948
[04-Jun-2013 20:52:52] ERROR: failed to ptrace(PEEKDATA) pid 17948: Input/output error (5)
[04-Jun-2013 20:52:52] NOTICE: finished trace of 17948
[04-Jun-2013 20:58:22] WARNING: [pool www] child 18287, script '/home/site/public_html/index.php' (request: "POST /index.php") executing too slow (10.701504 sec), logging
[04-Jun-2013 20:58:22] NOTICE: child 18287 stopped for tracing
[04-Jun-2013 20:58:22] NOTICE: about to trace 18287
[04-Jun-2013 20:58:22] NOTICE: finished trace of 18287
[04-Jun-2013 21:19:22] WARNING: [pool www] child 18224, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (10.005466 sec), logging
[04-Jun-2013 21:19:22] WARNING: [pool www] child 18197, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (12.141221 sec), logging
[04-Jun-2013 21:19:22] WARNING: [pool www] child 17946, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (11.107080 sec), logging
[04-Jun-2013 21:19:22] NOTICE: child 17946 stopped for tracing
[04-Jun-2013 21:19:22] NOTICE: about to trace 17946
[04-Jun-2013 21:19:22] NOTICE: finished trace of 17946
[04-Jun-2013 21:19:22] NOTICE: child 18197 stopped for tracing
[04-Jun-2013 21:19:22] NOTICE: about to trace 18197
[04-Jun-2013 21:19:22] NOTICE: finished trace of 18197
[04-Jun-2013 21:19:22] NOTICE: child 18224 stopped for tracing
[04-Jun-2013 21:19:22] NOTICE: about to trace 18224
[04-Jun-2013 21:19:22] NOTICE: finished trace of 18224
[04-Jun-2013 21:19:26] WARNING: [pool www] child 18197, script '/home/site/public_html/index.php' (request: "GET /index.php") execution timed out (15.475021 sec), terminating
[04-Jun-2013 21:19:26] WARNING: [pool www] child 18055, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (12.927407 sec), logging
[04-Jun-2013 21:19:26] NOTICE: child 18055 stopped for tracing
[04-Jun-2013 21:19:26] NOTICE: about to trace 18055
[04-Jun-2013 21:19:26] NOTICE: finished trace of 18055
[04-Jun-2013 21:19:26] WARNING: [pool www] child 18197 exited on signal 15 (SIGTERM) after 4094.193190 seconds from start
[04-Jun-2013 21:19:26] NOTICE: [pool www] child 5137 started
[04-Jun-2013 21:24:49] WARNING: [pool www] child 17918, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (11.367854 sec), logging
[04-Jun-2013 21:24:49] NOTICE: child 17918 stopped for tracing
[04-Jun-2013 21:24:49] NOTICE: about to trace 17918
[04-Jun-2013 21:24:49] NOTICE: finished trace of 17918
[04-Jun-2013 21:24:53] WARNING: [pool www] child 18226, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (10.763667 sec), logging
[04-Jun-2013 21:24:53] WARNING: [pool www] child 18206, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (12.060464 sec), logging
[04-Jun-2013 21:24:53] WARNING: [pool www] child 18073, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (11.846097 sec), logging
[04-Jun-2013 21:24:53] NOTICE: child 18073 stopped for tracing
[04-Jun-2013 21:24:53] NOTICE: about to trace 18073
[04-Jun-2013 21:24:53] NOTICE: finished trace of 18073
[04-Jun-2013 21:24:53] NOTICE: child 18206 stopped for tracing
[04-Jun-2013 21:24:53] NOTICE: about to trace 18206
[04-Jun-2013 21:24:53] NOTICE: finished trace of 18206
[04-Jun-2013 21:24:53] NOTICE: child 18226 stopped for tracing
[04-Jun-2013 21:24:53] NOTICE: about to trace 18226
[04-Jun-2013 21:24:53] NOTICE: finished trace of 18226
[04-Jun-2013 21:24:56] WARNING: [pool www] child 5137, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (12.055624 sec), logging
[04-Jun-2013 21:24:56] WARNING: [pool www] child 18206, script '/home/site/public_html/index.php' (request: "GET /index.php") execution timed out (15.395149 sec), terminating
[04-Jun-2013 21:24:56] WARNING: [pool www] child 17996, script '/home/site/public_html/index.php' (request: "GET /index.php") executing too slow (12.145728 sec), logging
[04-Jun-2013 21:24:56] WARNING: [pool www] child 17918, script '/home/site/public_html/index.php' (request: "GET /index.php") execution timed out (18.036700 sec), terminating
[04-Jun-2013 21:24:56] NOTICE: child 17996 stopped for tracing
[04-Jun-2013 21:24:56] NOTICE: about to trace 17996
[04-Jun-2013 21:24:56] NOTICE: finished trace of 17996
[04-Jun-2013 21:24:56] NOTICE: child 5137 stopped for tracing
[04-Jun-2013 21:24:56] NOTICE: about to trace 5137
[04-Jun-2013 21:24:56] NOTICE: finished trace of 5137
[04-Jun-2013 21:24:56] WARNING: [pool www] child 17918 exited on signal 15 (SIGTERM) after 4424.343036 seconds from start
[04-Jun-2013 21:24:56] NOTICE: [pool www] child 6706 started
[04-Jun-2013 21:24:56] WARNING: [pool www] child 18206 exited on signal 15 (SIGTERM) after 4424.264130 seconds from start
[04-Jun-2013 21:24:56] NOTICE: [pool www] child 6707 started
[04-Jun-2013 21:24:59] WARNING: [pool www] child 17996, script '/home/site/public_html/index.php' (request: "GET /index.php") execution timed out (15.479201 sec), terminating
[04-Jun-2013 21:24:59] WARNING: [pool www] child 17996 exited on signal 15 (SIGTERM) after 4427.655572 seconds from start
[04-Jun-2013 21:24:59] NOTICE: [pool www] child 6708 started
這是我的nginx配置
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
worker_rlimit_nofile 20000;
events {
#worker_connections 768;
#worker_connections 19000;
#multi_accept on;
use epoll;
#worker_connections 10240;
worker_connections 4096;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 65;
#keepalive_timeout 5;
#added
client_body_timeout 15;
client_header_timeout 15;
keepalive_timeout 15;
send_timeout 15;
site.conf
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
#fastcgi_buffers 256 16k; #4096k total
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
php5-fpm通過TCP端口連接
謝謝
總結(jié)
以上是生活随笔為你收集整理的nginx php fpm 连接数,哪个php5-fpm设置为高并发连接数nginx的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 内存选购全攻略:一步步教你如何挑选适合自
- 下一篇: 动态规划算法php,php算法学习之动态