什么是ab
ab是用于对Apache超文本传输协议(HTTP)服务器进行基准测试的工具
ab(apache benchmark)安装
yum -y install httpd-tools
使用示例
ab -n 1000 -c 200 http://localhost:3001/
## 模拟1000个请求,由200个用户
-n: 表示1000请求数
-c: 表示200并发数
结果说明
$ ab -n 1000 -c 200 https://www.baidu.com/
## apache版本信息
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
…………
## 服务器软件
Server Software: BWS/1.1
Server Hostname: www.baidu.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
Server Temp Key: ECDH P-256 256 bits
TLS Server Name: www.baidu.com
Document Path: /
Document Length: 227 bytes
## 并发数
Concurrency Level: 200
## 共使用了多少时间
Time taken for tests: 7.798 seconds
## 请求数
Complete requests: 1000
## 失败请求数
Failed requests: 0
## 总共传输字节数,包含http的头信息等
Total transferred: 1110951 bytes
## html字节数,实际的页面传递字节数
HTML transferred: 227000 bytes
## 服务器的吞吐量;每秒多少请求,这个是非常重要的参数数值,
Requests per second: 128.23 [#/sec] (mean)
## 用户平均请求等待时间
Time per request: 1559.692 [ms] (mean)
## 服务器平均处理时间,也就是服务器吞吐量的倒数
Time per request: 7.798 [ms] (mean, across all concurrent requests)
## 每秒获取的数据长度
Transfer rate: 139.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 106 1085 187.4 1110 1691
Processing: 132 382 141.2 323 706
Waiting: 27 375 138.5 322 690
Total: 317 1467 192.4 1453 1976
Percentage of the requests served within a certain time (ms)
50% 1453
66% 1555
75% 1617
80% 1650
90% 1747
95% 1784
98% 1833
99% 1863
100% 1976 (longest request)