压测—ab

ab(apache bench):apache下的一个工具,主要用于做web站点的压力测试

 1. Ubuntu安裝ab命令

sudo apt-get install apache2-utils

 若报错:

Err:1 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-utils amd64 2.4.29-1ubuntu4.14
  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-utils_2.4.29-1ubuntu4.14_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

解决方式:

(1)修改源:sudo gedit /etc/apt/sources.list

(2)打开的文件最后添加如下两行

        deb http://dk.archive.ubuntu.com/ubuntu/ xenial main

        deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe

(3)更新源:sudo apt update

(4)再次安装:sudo apt-get install apache2-utils

 2. 常用参数

执行ab --help查看参数:

     -n:总共的请求执行数,缺省是1;
     -c:并发数,缺省是1;
     -t:测试所进行的总时间,秒为单位,缺省50000s
     -p:POST时的数据文件
     -w: 以HTML表的格式输出结果 

3. 执行结果

执行    ab -n 5000 -c 200 http://localhost/test.php:

Benchmarking localhost (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests   //执行完的请求次数


Server Software:        Apache/2.4.3     //apache版本
Server Hostname:        localhost        //主机  
Server Port:            80               //端口

Document Path:          /test.php         //路径
Document Length:        62492 bytes       

Concurrency Level:      200                 //并发数
Time taken for tests:   3.927 seconds       //完成此次请求时间
Complete requests:      5000                //完成请求次数
Failed requests:        527                 //失败的请求次数
   (Connect: 0, Receive: 0, Length: 527, Exceptions: 0)
Total transferred:      313289422 bytes         //总共传输字节
HTML transferred:       312459422 bytes
Requests per second:    1273.33 [#/sec] (mean)    //每秒请求次数:平均每秒处理1273个请求次数
Time per request:       157.069 [ms] (mean)       //一次请求时间:平均每个请求处理时间为157毫秒
Time per request:       0.785 [ms] (mean, across all concurrent requests) //平均每个并发请求处理 时间 为0.785毫秒
Transfer rate:          77914.14 [Kbytes/sec] received       //传输速率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    6  73.1      0    1001
Processing:     2  150 143.9    111    1626
Waiting:        2  137 135.3    103    1197
Total:          2  155 160.3    111    1626

Percentage of the requests served within a certain time (ms)
  50%    111      //在这5000个请求中有50%在111毫秒内完成
  66%    141      //在这5000个请求中有66%在141毫秒内完成 
  75%    168
  80%    191
  90%    310
  95%    452
  98%    673
  99%    951
 100%   1626 (longest request)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

满腹的小不甘

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

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

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

打赏作者

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

抵扣说明:

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

余额充值