ab是一种用于测试Apache超文本传输协议(HTTP)服务器的工具。apache自带ab工具,可以测试
apache、IIs、tomcat、nginx等服务器
但是ab没有Jmeter、Loadrunner那样有各种场景设计、各种图形报告和监控,只需一个命令即可,有输出描述
可以简单的进行一些压力测试
一、Mac下自带apache
查看版本 apachectl -v
以请求百度为例:http://httpd.apache.org/docs/2.4/programs/ab.html 详细说明见官网
ab命令同时满足http及https的请求
常用请求参数:-n请求次数,-c并发数
Wx-MacBookPro:apache2 wuxi$ ab -n 100 -c 10 https://www.baidu.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
//apache版本信息
Benchmarking www.baidu.com (be patient).....done
Server Software: BWS/1.1
//请求返回header类型,可能是nginx、apache、IIs等
Server Hostname: www.baidu.com
//请求ip或者域名
Server Port: 443
//请求端口,当前请求为https所以端口为443,请求https端口80
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
//https端口协议
TLS Server Name: www.baidu.com
Document Path: /
//路径
Document Length: 227 bytes
//第一个成功返回的文档的字节大小
Concurrency Level: 10
//并发数!!!
Time taken for tests: 1.034 seconds
//从建立连接到最后接受完成总时间
Complete requests: 100
//总请求数成功的
Failed requests: 0
//失败的
Total transferred: 87200 bytes
//从服务器接收的字节总数
HTML transferred: 22700 bytes
//HTML接收字节数
Requests per second: 96.75 [#/sec] (mean)
————每秒请求数(总请求数/总时间)
Time per request: 103.359 [ms] (mean)
————用户平均请求等待时间=concurrency * timetaken * 1000 / done
参考Jmeter、LR中的平均响应时间
Time per request: 10.336 [ms] (mean, across all concurrent requests)
————服务器处理每个请求平均响应时间=timetaken * 1000 / done
Transfer rate: 82.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 41 75 16.1 74 121
Processing: 10 23 12.7 19 63
Waiting: 10 21 10.8 18 54
Total: 62 99 18.5 97 168
//网络连接情况
Percentage of the requests served within a certain time (ms)
50% 97
66% 104
75% 107
80% 110
90% 126
95% 138
98% 148
99% 168
100% 168 (longest request)
//整体响应时间的分布比
原文地址:https://www.cnblogs.com/haiyan123/p/9577594.html