Linux
阿帕奇瓶頸
我有 nginx 作為前端代理和帶有 mod_fcgid 的 apache。
這個盒子有 24GB RAM 和 16 個核心。我不應該成為瓶頸。
似乎有瓶頸。一旦達到 7000 個請求,它就會在繼續之前掛起。
編輯3:有人可以解釋
PHP_FCGI_CHILDREN
嗎?我將它設置為 1 並且東西似乎工作得更好。設置得越高越好嗎?它真的跨越了很多過程,就像瘋了一樣。編輯:錯誤日誌明智:
(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
編輯 - 問題 2 因為我使用 nginx 作為前端代理。是否有可能我正在最大化我的所有埠,因此無法再發送到後端(apache)?我還注意到 PHP procs 死得很快
16409 USER 20 0 0 0 0 Z 27.2 0.0 0:00.82 [php] <defunct>
即使有這樣的事情,它也會失敗:
/usr/local/apache/bin/ab -n 1000000 -c 10 http://IP/index.php apr_poll: The timeout specified has expired (70007) Total of 23998 requests completed
我的結果:
/usr/local/apache/bin/ab -n 10000 -c 100 http:///index.php Document Path: /index.php Document Length: 55764 bytes Concurrency Level: 100 Time taken for tests: 52.076 seconds Complete requests: 10000 Failed requests: 17 (Connect: 0, Receive: 0, Length: 17, Exceptions: 0) Write errors: 0 Non-2xx responses: 17 Total transferred: 558563436 bytes HTML transferred: 556703249 bytes Requests per second: 192.03 [#/sec] (mean) Time per request: 520.764 [ms] (mean) Time per request: 5.208 [ms] (mean, across all concurrent requests) Transfer rate: 10474.46 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.4 0 6 Processing: 3 436 3978.0 3 52069 Waiting: 2 436 3978.0 3 52069 Total: 3 436 3978.1 3 52073 Percentage of the requests served within a certain time (ms) 50% 3 66% 4 75% 4 80% 4 90% 5 95% 5 98% 1018 99% 29055 100% 52073 (longest request)
/etc/sysctl.conf
net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.conf.all.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.tcp_fin_timeout = 25 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_sack = 1 net.ipv4.tcp_fack = 1 net.ipv4.tcp_timestamps = 1 net.ipv4.tcp_syncookies = 1 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_ignore_bogus_error_responses = 1 net.ipv4.tcp_reordering = 5 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 3 net.ipv4.tcp_max_syn_backlog = 2048 net.core.netdev_max_backlog = 1024 net.core.hot_list_length = 256 net.ipv4.tcp_max_tw_buckets = 360000 net.core.rmem_default = 65535 net.core.rmem_max = 8388608 net.ipv4.tcp_rmem = 4096 87380 8388608 net.core.wmem_default = 65535 net.core.wmem_max = 8388608 net.ipv4.tcp_wmem = 4096 65535 8388608 net.ipv4.tcp_mem = 8388608 8388608 8388608 net.core.optmem_max = 40960 net.ipv4.netfilter.ip_conntrack_max = 32768 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_tw_reuse = 0 net.ipv4.tcp_orphan_retries = 1 net.ipv4.tcp_fin_timeout = 25 net.ipv4.tcp_max_orphans = 8192 net.ipv4.ip_local_port_range = 2768 61000 fs.file-max = 209708
/usr/local/cpanel/cgi-sys/php5
export PHP_FCGI_CHILDREN=0 exec /usr/bin/php
/usr/local/apache/conf/php.conf
LoadModule fcgid_module modules/mod_fcgid.so MaxRequestsPerProcess 1000 FcgidMaxProcesses 200 FcgidProcessLifeTime 3600 MaxProcessCount 200 FcgidIOTimeout 2000 FcgidIdleTimeout 60 FcgidIdleScanInterval 30 FcgidBusyTimeout 300 FcgidBusyScanInterval 80 ErrorScanInterval 3 ZombieScanInterval 3 FcgidMinProcessesPerClass 5 FcgidMaxProcessesPerClass 150 DefaultMinClassProcessCount 5 DefaultMaxClassProcessCount 150 IPCCommTimeout 40 IPCConnectTimeout 10 MaxRequestLen 1073741824 AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5 FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4 FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3 FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2 FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
阿帕奇
Timeout 5 TraceEnable Off ServerSignature Off ServerTokens ProductOnly FileETag None StartServers 15 <IfModule prefork.c> MinSpareServers 5 MaxSpareServers 10 </IfModule> ServerLimit 256 MaxClients 150 MaxRequestsPerChild 1000 KeepAlive Off KeepAliveTimeout 1 MaxKeepAliveRequests 1
httpd -V
Server version: Apache/2.2.23 (Unix) Server built: Jan 29 2013 11:18:48 Cpanel::Easy::Apache v3.16.7 rev9999 Server's Module Magic Number: 20051115:31 Server loaded: APR 1.4.6, APR-Util 1.4.1 Compiled using: APR 1.4.6, APR-Util 1.4.1 Architecture: 64-bit Server MPM: Event threaded: yes (fixed thread count) forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/experimental/event" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/usr/local/apache" -D SUEXEC_BIN="/usr/local/apache/bin/suexec" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"
nginx錯誤日誌
2013/02/06 18:12:50 [notice] 15123#0: signal 17 (SIGCHLD) received 2013/02/06 18:12:50 [notice] 15123#0: worker process 15127 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: worker process 15128 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: worker process 15129 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: worker process 15131 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: worker process 15137 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: worker process 15139 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: signal 29 (SIGIO) received 2013/02/06 18:12:50 [notice] 15123#0: signal 17 (SIGCHLD) received 2013/02/06 18:12:50 [notice] 15123#0: worker process 15124 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: signal 29 (SIGIO) received 2013/02/06 18:12:50 [notice] 15123#0: signal 17 (SIGCHLD) received 2013/02/06 18:12:50 [notice] 15123#0: worker process 15136 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: signal 29 (SIGIO) received 2013/02/06 18:12:50 [notice] 15123#0: signal 17 (SIGCHLD) received 2013/02/06 18:12:50 [notice] 15123#0: worker process 15125 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: signal 29 (SIGIO) received 2013/02/06 18:12:50 [notice] 15123#0: signal 17 (SIGCHLD) received 2013/02/06 18:12:50 [notice] 15123#0: worker process 15130 exited with code 0 2013/02/06 18:12:50 [notice] 15123#0: signal 29 (SIGIO) received
如果您已經將 ngix 用於反向代理,並且我假設也用於提供靜態文件,那麼
mod_fcgi
這只是一個複雜的問題 - 只需使用 apachemod_php
和相當高的maxclients
和serverlimit
(類似於 1024)。
您是否在與伺服器不同的機器上執行基準測試?伺服器上的網路連結速度是多少?您可能會最大化網路頻寬。
Transfer rate: 10474.46 [Kbytes/sec] received
這看起來有點像 10MB/s