我有nginx作为前端代理和Apache与mod_fcgid。
这个盒子有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 /本地/的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只是一个复杂的问题 – 只要使用mod_php和合理高的maxclients和serverlimit (类似于1024)就可以使用apache。
你是否在单独的机器上运行基准testing? 服务器上的networking链接速度是多less? 您可能会使networking带宽达到最大。
Transfer rate: 10474.46 [Kbytes/sec] received
这看起来像10MB / s可疑
在5秒内服务的请求的百分比是95,然后突然跳到服务器的1018秒只有98%。 它也发生,你的Apache超时设置为5秒。 我认为默认的Apache的默认超时值通常设置为大于120秒。 有什么理由把它设置为5秒? 你有没有考虑增加它?
95% 5 98% 1018