zl程序教程

您现在的位置是:首页 >  系统

当前栏目

ubuntu21.10(linux): 安装和使用ab(ApacheBench, Version 2.3)

Linux安装 version 2.3 AB 使用
2023-09-14 08:59:32 时间

一,安装ab:

1,安装
root@lhdpc:~# apt-get install httpd-tools
2,查看安装的路径
root@lhdpc:~# whereis ab
ab: /usr/bin/ab /usr/share/man/man1/ab.1.gz 
3,查看ab的版本:
root@lhdpc:~# ab -V
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,测试效果

例子:10个并发,总数100次访问
liuhongdi@lhdpc:/data/php/admapi/app$ ab -c 10 -n 100 http://192.168.219.6:8000/goods/detail?goodsid=12323
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 192.168.219.6 (be patient).....done
 
 
Server Software:        nginx/1.18.0
Server Hostname:        192.168.219.6
Server Port:            8000
 
Document Path:          /goods/detail?goodsid=12323
Document Length:        37 bytes
 
Concurrency Level:      10
Time taken for tests:   0.059 seconds
Complete requests:      10
Failed requests:        7
   (Connect: 0, Receive: 0, Length: 7, Exceptions: 0)
Total transferred:      2276 bytes
HTML transferred:       496 bytes
Requests per second:    169.79 [#/sec] (mean)
Time per request:       58.897 [ms] (mean)
Time per request:       5.890 [ms] (mean, across all concurrent requests)
Transfer rate:          37.74 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.5      1       2
Processing:    12   26  11.0     25      44
Waiting:       11   26  11.2     25      44
Total:         13   27  10.9     26      45
 
Percentage of the requests served within a certain time (ms)
  50%     26
  66%     29
  75%     37
  80%     42
  90%     45
  95%     45
  98%     45
  99%     45
100%     45 (longest request)

三,查看linux的版本:

root@lhdpc:~# more /etc/os-release
PRETTY_NAME="Ubuntu 21.10"
NAME="Ubuntu"
VERSION_ID="21.10"
VERSION="21.10 (Impish Indri)"
VERSION_CODENAME=impish
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=impish