小测试apache与nginx请求速度的对比
原创jinga50334 博主文章分类:linux/unix/开源 ©著作权
©著作权归作者所有:来自51CTO博客作者jinga50334的原创作品,请联系作者获取转载授权,否则将追究法律责任
今天用apache的小工具ab测试apache及nginx两个webserver的响应速度。平时总能在网上看到nginx比apache如何如何强的帖子,但自己从来没有测试过。今天有空测试了一下。相同的代码、相同网络状况相同的数据库。
对比情况如下:
apache:
Document Length: 3960 bytes
Concurrency Level: 10
Time taken for tests: 0.604543 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 42400 bytes
HTML transferred: 39600 bytes
Requests per second: 16.54 [#/sec] (mean)
Time per request: 604.543 [ms] (mean)
Time per request: 60.454 [ms] (mean, across all concurrent requests)
Transfer rate: 67.82 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 2 0.0 2 2
Processing: 22 363 252.5 390 602
Waiting: 21 275 175.3 382 389
Total: 24 365 252.5 392 604
Percentage of the requests served within a certain time (ms)
50% 392
66% 598
75% 602
80% 602
90% 604
95% 604
98% 604
99% 604
100% 604 (longest request)
nginx:
Document Length: 3960 bytes
Concurrency Level: 10
Time taken for tests: 0.104265 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 42120 bytes
HTML transferred: 39600 bytes
Requests per second: 95.91 [#/sec] (mean)
Time per request: 104.265 [ms] (mean)
Time per request: 10.426 [ms] (mean, across all concurrent requests)
Transfer rate: 393.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 9 11 2.1 11 15
Processing: 29 61 21.2 70 88
Waiting: 25 59 21.7 68 87
Total: 38 73 23.0 81 103
Percentage of the requests served within a certain time (ms)
50% 81
66% 87
75% 92
80% 101
90% 103
95% 103
98% 103
99% 103
100% 103 (longest request)
apache:最长响应的时间——604ms 每秒事务数——16.54 [#/sec] 平均事务响应时间——604.543 [ms]
nginx:最长响应的时间——103ms 每秒事务数——95.91 [#/sec] 平均事务响应时间——104.265 [ms]
想到过nginx比apache强,但是都是别人说的自己是头一回亲眼见证,这大大的增强了我更换webserver的决心。
至于有人说:apache比起nginx相对安全与稳定就如上面的说法一样,我也是听别人说的。回头自己亲自测试一下。实践方能出真知!
测试命令:
ab -n 10 -c 10 http://www.microsoft.com/
-n:发请求次数
-c:每次发请求的数量(并发concurrency )
上一篇:nginx 如何显示真实ip
下一篇:解决被EMOS屏蔽的IP

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
数据库读取速度与文件IO读取速度比较
记下 DB 存取与文件存取的差异 本文来源于之前做的一个小程序科技
数据库 java mysql python 大数据