日期:2014-05-17  浏览次数:20774 次

Nginx和Apache简单的并发压力测试

同样的环境,大小差不了几个字节的页面,

Nginx的worker_connections? 1024;

Apache的MaxClients????????? 150,worker模式;


照理说压Nginx如果用1024个并发压效果是最好的,同样压apache并发150的话效果也是最好的。


Nginx的测试结果:

[root@localhost nginx-0.7.19]# ab -t 60 -c 1024 http://192.168.1.101:8080/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Finished 50000 requests Server Software: nginx/0.7.19 Server Hostname: 192.168.1.101 Server Port: 8080 Document Path: / Document Length: 151 bytes Concurrency Level: 1024 Time taken for tests: 28.791802 seconds Complete requests: 50000 Failed requests: 0 Write errors: 0 Total transferred: 18100000 bytes HTML transferred: 7550000 bytes Requests per second: 1736.61 [#/sec] (mean) Time per request: 589.656 [ms] (mean) Time per request: 0.576 [ms] (mean, across all concurrent requests) Transfer rate: 613.89 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 19.0 0 2998 Processing: 33 531 448.3 458 3452 Waiting: 10 298 457.2 237 3415 Total: 33 531 448.7 458 3452 Percentage of the requests served within a certain time (ms) 50% 458 66% 466 75% 478 80% 483 90% 502 95% 599 98% 3409 99% 3428 100% 3452 (longest request)






Nginx5000个请求只花费了28秒就搞定。


Apache的测试结果:

[root@localhost nginx-0.7.19]# ab -t 60 -c 150 http://192.168.1.101/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Finished 39842 requests Server Software: Apache/2.2.10 Server Hostname: 192.168.1.101 Server Port: 80 Document Path: / Document Length: 44 bytes Concurrency Level: 150 Time taken for tests: 60.74169 seconds Complete requests: 39842 Failed requests: 0 Write errors: 0 Total transferred: 11953500 bytes HTML transferred: 1753180 bytes Requests per second: 663.21 [#/sec] (mean) Time per request: 226.172 [ms] (mean) Time per request: 1.508 [ms] (mean, across all concurrent requests) Transfer rate: 194.31 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 47.5 0 3000 Processing: 62 223 696.2 111 12013 Waiting: 0 156 605.3 58 9025 Total: 62 224 701.2 111 12013 Percentage of the requests served within a certain time (ms) 50% 111 66% 119 75% 125 80% 129 90% 159 95% 191 98% 3011 99% 3017 100% 12013 (longest request)





Apache一分钟只搞定了4000个请求。


再试试,Nginx的并发150时候的速度:

[root@localhost nginx-0.7.19]# ab -t 60 -c 150 http://192.168.1.101:8080/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.116 $> apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.1.101 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Finished 50000 requests Server Software: nginx/0.7.19 Se