压测工具之ab(ApacheBench)安装及使用

安装

yum -y install httpd-tools

基本用法

  • 100w请求,400并发测试。
$ ab -c 400 -n 1000000 http://localhost:8888/bm/redis/put/100
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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) #压测进度
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Completed 1000000 requests
Finished 1000000 requests


Server Software:
Server Hostname:        localhost
Server Port:            8888

Document Path:          /bm/redis/put/100
Document Length:        16 bytes

Concurrency Level:      400
Time taken for tests:   155.041 seconds
Complete requests:      1000000
Failed requests:        0
Write errors:           0
Total transferred:      95000000 bytes
HTML transferred:       16000000 bytes
Requests per second:    6449.92 [#/sec] (mean)
Time per request:       62.016 [ms] (mean)
Time per request:       0.155 [ms] (mean, across all concurrent requests)
Transfer rate:          598.38 [Kbytes/sec] received

Connection Times (ms)  #请求处理分析
              min  mean[+/-sd] median   max
Connect:        0   41 237.0      0   15035
Processing:     0   21  12.8     20    1618
Waiting:        0   21  12.8     20    1618
Total:          0   62 238.7     20   15056

Percentage of the requests served within a certain time (ms) #请求时间百分比分布
  50%     20
  66%     21
  75%     22
  80%     22
  90%     24
  95%     30
  98%   1022
  99%   1025
 100%  15056 (longest request) #最大请求时间

 

 

其他参数

Options are:
    -n requests     本次总请求数
    -c concurrency  并发数
    -t timelimit    基础压测最大时间(秒),基于-n 50000的情况下最大测试时间,默认不显示。
    -s timeout      请求超时时间(秒),默认30秒
    -b windowsize   缓冲区大小(字节)
    -B address      Address to bind to when making outgoing connections
    -p postfile     POST请求文件,需要设置 -T
    -u putfile      PUT请求文件. 需要设置 -T
    -T content-type POST/PUT请求header中的content-type值,默认是'text/plain'
    -v verbosity    显示多少故障信息,1/2/3/4
    -w              在html中显示结果
    -i              使用head请求,默认是get
    -x attributes   设置table属性
    -y attributes   设置tr属性
    -z attributes   设置th属性
    -C attribute    添加cookie, 如:'Apache=1234',可重复
    -H attribute    添加header, 如:'Accept-Encoding: gzip',追加常规header后面,可重复。               
    -A attribute    添加WWW认证信息, 格式'user:pwd'
    -P attribute    添加基础身份认证信息,格式'user:pwd'
    -X proxy:port   使用的代理服务端口
    -V              显示版本
    -k              使用http连接保持功能
    -d              不显示时间百分比分布.
    -S              不显示中位数和警告
    -q              总请求数大于150时,不显示测试请求进度(Benchmarking localhost)。
    -g filename     输出测试数据到指定文件.
    -e filename     输出百分比CSV文件
    -r              收到错误信息不退出
    -h              显示帮助信息
    -Z ciphersuite  指定SSL/TLS密码套件,参考openssl
    -f protocol     指定SSL/TLS协议,如:(SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lizz666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值