ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

压测—ab

2021-08-04 11:06:34  阅读:250  来源: 互联网

标签:ab 请求 压测 Completed apache2 5000 ubuntu requests


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)

标签:ab,请求,压测,Completed,apache2,5000,ubuntu,requests
来源: https://blog.csdn.net/qq_27586341/article/details/119377845

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有