Apache ab 测试工具使用(一)

简述:

试用apache ab测试工具


下载点

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

参考:

http://jingyan.baidu.com/article/e3c78d647a57833c4c85f502.html


ab的参数说明

-n  需要执行的请求次数

-c  并发的数量

-t   等待返回的最长时间

-b  TCP收发缓冲区的大小,单位(byte)

-p 使用post (同时需要定义-T参数)

-u 使用put (同时需要定义-T参数)

-T content-type, 例如application/x-www-form-urlencoded, 默认为text/plain

-w 把结果打印在html的表格里

-x  表格的属性

-y  tr行属性

-z  td列属性

-C 设置cookie 例如Apach=1234

-H header行, 例如Accept-Encoding:gzip

-k 是否标示位HTTP Keep Alive




步骤:

1. 配置环境变量



配置完成



2. 下面就拿apache的一个静态页面做测试

测试command,

ab -n 1000 -c 100 -w http://localhost/a.htm >>C:\Users\Administrator\Desktop\ab_test\result.html




测试结果:

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/

Benchmarking localhost (be patient)


Server Software:        Apache/2.2.25
Server Hostname:        localhost
Server Port:            80

Document Path:          /a.htm
Document Length:        319 bytes

Concurrency Level:      100
Time taken for tests:   0.325 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      581000 bytes
HTML transferred:       319000 bytes
Requests per second:    3076.74 [#/sec] (mean)
Time per request:       32.502 [ms] (mean)
Time per request:       0.325 [ms] (mean, across all concurrent requests)
Transfer rate:          1745.69 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:    11   31   5.2     31      45
Waiting:       11   31   5.2     30      45
Total:         12   31   5.2     31      46

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     32
  75%     33
  80%     35
  90%     38
  95%     40
  98%     42
  99%     43
 100%     46 (longest request)


附:

测试页面如下



下面是带参数的请求,

ab -n 1000 -c 100 -p C:\Users\Administrator\Desktop\ab_test\params.txt -T application/x-www-form-urlencoded http://localhost/result.html >>C:\Users\Administrator\Desktop\ab_test\result.html


如果是带有cookie的请求

param.txt

trainId=aaaa&topicCategory=b&topicRelation=a&userRoleCode=a1&searchText=


command:

ab -n 10 -c 5 -p C:\Users\Administrator\Desktop\ab_test\params.txt -C "JSESSIONID=v1234hjwcx8k1e8trwh1ipjso; paramA=5322155; paramB=V12EE0186; edu.yale.its.tp.cas.client.filter.receipt=23/20/49/23/23/21/23/124/69/48/48/20/21/48/49/26/24/124/116/101/108/101/99/111/109/124/49/22/48/22/49/21/22/24/23/21/49/49/27/" -T application/x-www-form-urlencoded -w http://127.0.0.1:8080/cpa/topic/student/getTopicInfo >>C:\Users\Administrator\Desktop\ab_test\result.html


最后查看html的测试结果



测试结果:






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值