天天看点

apache 压力测试工具ab(apache benchmark)

ab的全称是ApacheBench,是 Apache 附带的一个小工具,专门用于 HTTP Server 的benchmark testing,可以同时模拟多个并发请求。

C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 10 -c 10 http ://www.google.com/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.google.com (be patient).....done

Server Software:        GWS/2.1 

Server Hostname:        www.google.com 

Server Port:            80  

Document Path:          /index.html  

Document Length:        230 bytes

Concurrency Level:      10 

Time taken for tests:   3.234651 seconds 

Complete requests:      10 

Failed requests:        0 

Write errors:           0  

Total transferred:      6020 bytes

HTML transferred:       2300 bytes

Time per request:       3234.651 [ms] (mean)

Time per request:       323.465 [ms] (mean, across all concurrent requests)

Transfer rate:          1.55 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       20  318 926.1     30    2954

Processing:    40 2160 1462.0   3034    3154

Waiting:       40 2160 1462.0   3034    3154

Total:         60 2479 1276.4   3064    3184

Percentage of the requests served within a certain time (ms)

  50%   3064

  66%   3094

  75%   3124

  80%   3154

  90%   3184

  95%   3184

  98%   3184

  99%   3184

 100%   3184 (longest request)

更多信息

ab 不像 LR 那么强大,但是它足够轻便,如果只是在开发过程中想检查一下某个模块的响应情况,或者做一些场景比较简单的测试,ab 还是一个不错的选择——至少不用花费很多时间去学习 LR 那些复杂的功能,就更别说那 License 的价格了。

ab 是 Apache 的一个安装组件,所以需要下载 Apache 安装后才能使用,可以访问 Apache 的项目主页来下载

http://httpd.apache.org/download.cgi

ab 的更多信息可以参加 Apache 主页上的描述

http://httpd.apache.org/docs/2.0/programs/ab.html