注:本人使用Ubuntu文中其中一台从机就是,还有台CentOS服务器,资源有限报告有误差请谅解:)
本文是相对上一篇apache自带负载均衡的集群功能实战而作的报告
apacheBench(ab)
apache服务器自带有一个叫AB(ApacheBench)的工具,在bin目录下使用这个工具可以对服务器进行负载测试。
用法:
ab -n 全部请求数 -c 并发数 测试url
Concurrency Level: 50 #并发数
Time taken for tests: 92.76140 seconds #全部请求完成耗时
Complete requests: 10000 #全部请求数
Failed requests: 1974 #失败的请求
(Connect: 0, Length: 1974, Exceptions: 0)
Write errors: 0
Total transferred: 827019400 bytes #总传输大小
HTML transferred: 825219400 bytes
Requests per second: 108.61 [#/sec] (mean) #每秒请求数(平均)
Time per request: 460.381 [ms] (mean) #每次并发请求时间(所有并发)
Time per request: 9.208 [ms] (mean, across all concurrent requests) #每一请求时间(并发平均)
Transfer rate: 8771.39 [Kbytes/sec] received #传输速率
以下结果时间每次有所偏差,均取相对平均值。
下面是我的从机ubuntu环境下的测试结果,在主机CentOS那台机器上 测试时候性能差比较明显。但最好还是能有第三台外部机器来测。
--------------------------------------------------------------------------------
单台主服务器测试情况:
ab -n 1000 -c 100
Concurrency Level: 100
Time taken for tests: 0.573741 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 276925 bytes
HTML transferred: 14098 bytes
Requests per second: 1742.95 [#/sec] (mean)
Time per request: 57.374 [ms] (mean)
Time per request: 0.574 [ms] (mean, across all concurrent requests)
Transfer rate: 470.60 [Kbytes/sec] received
双机模式:
ab -n 1000 -c 100
Concurrency Level: 100
Time taken for tests: 0.621410 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 279375 bytes
HTML transferred: 14070 bytes
Requests per second: 1609.24 [#/sec] (mean)
Time per request: 62.141 [ms] (mean)
Time per request: 0.621 [ms] (mean, across all concurrent requests)
Transfer rate: 437.71 [Kbytes/sec] received
--------------------------------------------------------------------------------
ab -n 5000 -c 200
单机模式:用到此并发数时候数据的变化波动很大10-3秒內完成都有
Concurrency Level: 200
Time taken for tests: 10.5496 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 1375000 bytes
HTML transferred: 70000 bytes
Requests per second: 499.73 [#/sec] (mean)
Time per request: 400.220 [ms] (mean)
Time per request: 2.001 [ms] (mean, across all concurrent requests)
Transfer rate: 134.13 [Kbytes/sec] received
双机模式:稳定
Concurrency Level: 200
Time taken for tests: 2.408902 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 1391112 bytes
HTML transferred: 70056 bytes
Requests per second: 2075.63 [#/sec] (mean)
Time per request: 96.356 [ms] (mean)
Time per request: 0.482 [ms] (mean, across all concurrent requests)
Transfer rate: 563.74 [Kbytes/sec] received
--------------------------------------------------------------------------------
单台主服务器测试情况:开始响应超负荷
ab -n 3000 -c 500
apr_poll: The timeout specified has expired (70007)
Total of 4761 requests completed
双机模式:正常
ab -n 3000 -c 500
Concurrency Level: 500
Time taken for tests: 3.480663 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 834323 bytes
HTML transferred: 42014 bytes
Requests per second: 861.90 [#/sec] (mean)
Time per request: 580.111 [ms] (mean)
Time per request: 1.160 [ms] (mean, across all concurrent requests)
Transfer rate: 233.86 [Kbytes/sec] received
ab -n 5000 -c 500 //所用响应时间波动稍大
Concurrency Level: 500
Time taken for tests: 6.739712 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 1390137 bytes
HTML transferred: 70014 bytes
Requests per second: 741.87 [#/sec] (mean)
Time per request: 673.971 [ms] (mean)
Time per request: 1.348 [ms] (mean, across all concurrent requests)
Transfer rate: 201.34 [Kbytes/sec] received
ab -n 5000 -c 800
Concurrency Level: 800
Time taken for tests: 18.589927 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 1391184 bytes
HTML transferred: 70056 bytes
Requests per second: 268.96 [#/sec] (mean)
Time per request: 2974.388 [ms] (mean)
Time per request: 3.718 [ms] (mean, across all concurrent requests)
Transfer rate: 73.05 [Kbytes/sec] received
ab -n 5000 -c 1000
Concurrency Level: 1000
Time taken for tests: 23.19091 seconds
Complete requests: 5000
Failed requests: 1
(Connect: 0, Length: 1, Exceptions: 0)
Write errors: 0
Non-2xx responses: 1
Total transferred: 1390169 bytes
HTML transferred: 70448 bytes
Requests per second: 217.21 [#/sec] (mean)
Time per request: 4603.818 [ms] (mean)
Time per request: 4.604 [ms] (mean, across all concurrent requests)
Transfer rate: 58.95 [Kbytes/sec] received
--------------------------------------------------------------------------------
就不继续拉 目前相对一般的网站我想应该够了吧:)
小结:测试也是一们大课题,而ab是专门性针对apache的负载进行测试的其中一款软件在linux 下还有许多开源的好软件如:Siege、bombardment等,windows下的就更不用说拉,man慢慢来继续努力:)
阅读(2831) | 评论(1) | 转发(0) |