apache ab远程测试机测试(应用部署在本机,mysql部署在本机,但是ab测试由本地发起)
(参数解析,在本次测试中,-c 代表每次请求的连接数,-n 代表发起多少次请求,-k指的是启用http长连接)
[root@iZ948nttzx8Z bin]# ab -n 400 -c 400 -k http://120.25.98.197:8080/getAllArticles
(ab命令使用http长连接,向接口http://120.25.98.197:8080/getAllArticles请求了400次,每次(指1秒内)发起了400个连接)
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/
Concurrency Level: 400
Time taken for tests: 56.681 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Keep-Alive requests: 0
Total transferred: 5019448 bytes
HTML transferred: 4960100 bytes
Requests per second: 7.06 [#/sec] (mean)
Time per request: 56680.540 [ms] (mean)
Time per request: 141.701 [ms] (mean, across all concurrent requests)
Transfer rate: 86.48 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1570 2136.9 7 6595
Processing: 14 20957 12329.4 19054 56666
Waiting: 5 12335 14251.3 6487 56665
Total: 15 22527 11909.4 20746 56670
Percentage of the requests served within a certain time (ms)
50% 20746
66% 27694
75% 30274
80% 31638
90% 36210
95% 40453
98% 56273
99% 56477
100% 56670 (longest request)
apache ab本机测试(应用部署到本机,mysql部署到本机,ab测试由应用机发起)
[root@iZ94chsjsmvZ bin]# ab -n 400 -c 400 -k http://120.25.98.197:8080/getAllArticles
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/
Concurrency Level: 400 //并发数(秒)
Time taken for tests: 1.696 seconds //测试所花费的时间
Complete requests: 400 //完成请求的次数
Failed requests: 0 //请求失败次数
Write errors: 0
Keep-Alive requests: 0
Total transferred: 5045000 bytes //整个过程中的网络传输量
HTML transferred: 4985356 bytes //整个过程中的HTML 传输量
Requests per second: 235.81 [#/sec] (mean) //每秒请求数 后面括号中的mean表示这是一个平均值
Time per request: 1696.247 [ms] (mean) //相当于LR中的平均事务响应时间,后面括号中的mean表示这是一个平均值
Time per request: 4.241 [ms] (mean, across all concurrent requests) //每个连接请求实际运行时间的平均值
Transfer rate: 2904.50 [Kbytes/sec] received //平均每秒网络上的流量
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 132 318.2 0 1000
Processing: 13 366 137.9 409 830
Waiting: 5 360 136.8 398 830
Total: 57 498 377.3 415 1576
Percentage of the requests served within a certain time (ms)
50% 415
66% 442
75% 461
80% 475
90% 1423
95% 1488
98% 1567
99% 1572
100% 1576 (longest request)
总结下,结果看: 对比下俩次测试的最后四个参数 Requests per second: Time per request: Time per request: Transfer rate: 然后再看下服务器当时的网络进出流量监控可以发现apache ab远程测试机测试网络延时还是比较大的,所以本次测试肯定是不准的。
官网的意思是它是作为http server的测试工具,你如果想用来测web server也可以,但是可能不是很准,毕竟俩种是不同的服务,有测试组建议还是用jemeter,loadrunner。 原话是: ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving. 大体意思是它就是用来测http 每秒的并发请求数的,感觉用来测nginx还是可以的。