Nginx+PHP(FastCGI)测试


基本环境

单台1G内存兼容机
环境Nginx+ PHP(FastCGI)
在5000并发连接,开启的10个Nginx进程和20个php-cgi进程下,测试出效果很不寻常:)

# ./ab -c 5000 -n 5000 http://x.com/info.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking x.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software: nginx/0.6.32
Server Hostname: x.com
Server Port: 80

Document Path: /info.php
Document Length: 47854 bytes

Concurrency Level: 5000
Time taken for tests: 35.588 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 240080000 bytes
HTML transferred: 239270000 bytes
Requests per second: 140.50 [#/sec] (mean)
Time per request: 35587.975 [ms] (mean)
Time per request: 7.118 [ms] (mean, across all concurrent requests)
Transfer rate: 6587.99 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 9 17087 9859.7 15452 34242
Processing: 585 17355 9598.5 19018 33911
Waiting: 8 16389 9410.1 18042 32681
Total: 33920 34442 264.9 34511 35557

Percentage of the requests served within a certain time (ms)
50% 34511
66% 34609
75% 34669
80% 34713
90% 34772
95% 34800
98% 34817
99% 34823
100% 35557 (longest request)
跑PHP动态程序的处理能力达“140次请求/秒”,相当于每天可以承受超过1000万(140*60*60*24=12096000)的访问量

在Completed 3000 requests时随机监控了nginx活动状态和机器负载

>1.Nginx运行状态
Active connections: 4222 
server accepts handled requests
30589 30589 30609
Reading: 1 Writing: 4221 Waiting: 0


监控显示对后端发起的活动连接数Active connections:4222
nginx 总共处理30589个连接, 成功创建 30589次握手 (证明中间没有失败的), 总共处理了 30609个请求

nginx 读取到客户端的Header信息数1
nginx 返回给客户端的Header信息数4221
Nginx等候下一次请求指令的驻留连接0
Reading: 0 Writing: 10001 Waiting: 0



>2.top机器性能输出

top - 01:46:56 up 29 min, 2 users, load average: 1.99, 1.43, 1.07
Tasks: 81 total, 2 running, 79 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.3%us, 9.0%sy, 0.0%ni, 61.3%id, 0.0%wa, 0.0%hi, 3.3%si, 0.0%st
Mem: 956316k total, 314788k used, 641528k free, 7368k buffers
Swap: 2031608k total, 0k used, 2031608k free, 52800k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2122 nobody 15 0 53664 4076 2272 S 3.3 0.4 0:03.74 php-cgi
1926 nobody 15 0 44896 39m 784 S 2.7 4.2 0:18.44 nginx
2129 nobody 15 0 53664 4084 2272 S 2.7 0.4 0:04.40 php-cgi
2134 nobody 15 0 53664 4188 2336 S 2.7 0.4 0:04.16 php-cgi
2125 nobody 15 0 53664 4076 2272 S 2.3 0.4 0:04.44 php-cgi
2131 nobody 15 0 53664 4140 2336 S 2.3 0.4 0:03.38 php-cgi
2127 nobody 15 0 53664 4104 2284 S 2.0 0.4 0:03.98 php-cgi
2130 nobody 15 0 53664 4084 2272 S 2.0 0.4 0:04.09 php-cgi
2132 nobody 15 0 53664 4092 2280 S 2.0 0.4 0:03.22 php-cgi
2161 root 15 0 53632 33m 796 S 2.0 3.6 0:02.58 ab
2124 nobody 15 0 53664 4116 2284 S 1.7 0.4 0:03.99 php-cgi
2138 nobody 15 0 53664 4088 2272 S 1.7 0.4 0:03.87 php-cgi
2119 nobody 15 0 53928 4480 2412 S 1.3 0.5 0:04.72 php-cgi
2123 nobody 15 0 53664 4076 2272 S 1.3 0.4 0:04.16 php-cgi
2126 nobody 15 0 53664 4084 2272 S 1.3 0.4 0:03.51 php-cgi
2133 nobody 15 0 53796 4316 2284 S 1.3 0.5 0:03.22 php-cgi
2135 nobody 15 0 53664 4108 2272 S 1.3 0.4 0:03.00 php-cgi
2120 nobody 15 0 54060 4544 2272 S 1.0 0.5 0:07.66 php-cgi
2121 nobody 15 0 53664 4084 2280 S 1.0 0.4 0:04.41 php-cgi
2136 nobody 15 0 53664 4092 2280 S 1.0 0.4 0:02.98 php-cgi
2137 nobody 15 0 53664 4096 2284 S 1.0 0.4 0:03.85 php-cgi
2128 nobody 15 0 53664 4120 2284 S 0.7 0.4 0:03.75 php-cgi

你可能感兴趣的:(apache,PHP,nginx,活动,cgi)