ApacheBench学习

      ab 的全称是 ApacheBench   Apache 附带的一个小工具  专门用于 HTTP Server  benchmark testing 可以同时模拟多个并发请求。一般开发人员在进行真正的压力测试之前可以使用这个工具来进行自测,从而更好地掌握性能。

     首先进入安装Apache下的bin目录,比如在我本机就是C:\Program Files\Apache Software Foundation\Apache2.2\bin,较常用的参数是n和c,

-n1000,指定总请求数,-c10,指定并发数

运行命令  ab -n 10000 -c 100 http://renmai-dev.china.alibaba.com/view/attention/index/1.html  和结果如下:

     运行结果代码(重要参数:request per seconde 服务器每秒请求处理数)

C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 10000 -c 100 http://renmai-dev.china.alibaba.com/view/attention/index/1.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 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking renmai-dev.china.alibaba.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


Server Software:        Apache-Coyote/1.1
Server Hostname:        renmai-dev.china.alibaba.com
Server Port:            80

Document Path:          /view/attention/index/1.html
Document Length:        0 bytes

Concurrency Level:      100
Time taken for tests:   17.812500 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10000
Total transferred:      10130006 bytes
HTML transferred:       0 bytes
Requests per second:    561.40 [#/sec] (mean)
Time per request:       178.125 [ms] (mean)
Time per request:       1.781 [ms] (mean, across all concurrent requests)
Transfer rate:          555.34 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.8      0      31
Processing:    15  176 101.5    140    1125
Waiting:       15  176 101.3    140    1125
Total:         15  177 101.5    140    1125

Percentage of the requests served within a certain time (ms)
  50%    140
  66%    156
  75%    171
  80%    171
  90%    281
  95%    421
  98%    484
  99%    609
 100%   1125 (longest request)

请注意并发数最大为1024,取值不可大于此。接下来,比较一下压力更大的情况。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值