置顶

web性能测试工具ab的测试方法

作者:勇康博客网 | 分类:服务器 | 浏览:1130 | 日期:2021年08月10日

ab是一个apache中的一个工具。主要用户web网站的性能测试,压力测试,并发测试。这个工具可以方便模拟多线程并发请求测试服务器负载压力。

ab工具对发出负载的计算机资源占用很低,它既不会占用很高CPU和内存。但会给目标服务器造成巨大的负载,其原理类似CC攻击。所以测试使用也要根据实际需要进行测试,否则一次测试太多的负载。可能造成目标服务器资源耗尽而宕机

linux中安装ab工具

yum install https-tools

 查看ab的版本信息

ab -V

ab命令的测试


命令:ab

参数:-n 总请求数量    -c 并发数

案例:ab -n 1000 -c 100 http://localhost/index.html:80/index.html   (意思是100个人进行访问共完成1000次请求)

测试结果:

[root@localhost]# ab -n 100 -c 20 http://localhost:80/index.html
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).....done
Server Software:        nginx/1.12.0    #服务器软件
Server Hostname:        localhost    #域名
Server Port:            80  #端口  
Document Path:          /index.html    #页面
Document Length:        30397 bytes    #页面大小
Concurrency Level:      20    #并发数为20
Time taken for tests:   2.420 seconds    #总共请求时间
Complete requests:      100    #完成请求数
Failed requests:        0    #失败请求数
Write errors:           0    #写入错误
Total transferred:      3074900 bytes    #总传输量
HTML transferred:       3039700 bytes    #HTML内容传输量
Requests per second:    41.32 [#/sec] (mean)    #吞吐量=每秒最大请求数
Time per request:       483.985 [ms] (mean)    #服务器每个页面响应时间
#每个并发请求平均消耗时间
Time per request:       24.199 [ms] (mean, across all concurrent requests)
#平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
Transfer rate:          1240.88 [Kbytes/sec] received
#网络上消耗的时间的分解:
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:    95  424 102.5    430     594
Waiting:       95  423 102.5    430     594
Total:         95  424 102.5    430     594
#整个场景中所有请求的响应情况。
#在场景中每个请求都有一个响应时间 
#其中 50% 的用户响应时间小于 430 毫秒 
#80 % 的用户响应时间小于 485 毫秒 
#最大的响应时间小于 594 毫秒 
Percentage of the requests served within a certain time (ms)
  50%    430
  66%    470
  75%    480
  80%    485
  90%    560
  95%    586
  98%    592
  99%    594
 100%    594 (longest request)

发表评论

取消
微信二维码
微信二维码
支付宝二维码