httpd之ab压力测试

安装软件

yum install -y httpd

参数说明:
用法
Usage: ab [options] [http[s]://]hostname[:port]/path
用法:ab [选项] 地址

选项:
Options are:
-n requests #执行的请求数,即一共发起多少请求。
-c concurrency #请求并发数。
-s timeout #指定每个请求的超时时间,默认是30秒。
-k #启用HTTP KeepAlive功能,即在一个HTTP会话中执行多个请求。默认时,不启用KeepAlive功能。
压测命令
# 使用ab压测工具,对百度的链接 请求100次,并发数1
ab -n 100 -c 1 https://www.baidu.com/

Benchmarking www.baidu.com (be patient).....done

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

Document Path: /
Document Length: 227 bytes

Concurrency Level: 1
Time taken for tests: 2.798 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 108189 bytes
HTML transferred: 22700 bytes
Requests per second: 35.74 [#/sec] (mean)
Time per request: 27.977 [ms] (mean)
Time per request: 27.977 [ms] (mean, across all concurrent requests)
Transfer rate: 37.76 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 16 21 8.7 20 105
Processing: 6 7 1.9 7 26
Waiting: 6 7 1.9 7 25
Total: 22 28 9.2 27 113

Percentage of the requests served within a certain time (ms)
50% 27
66% 28
75% 28
80% 29
90% 29
95% 32
98% 50
99% 113
100% 113 (longest request)

主要关注的测试指标

Concurrency Level        -->并发请求数
Time taken for tests       -->整个测试时间
Complete requests        -->完成请求个数
Failed requests              -->失败个数
Requests per second    -->吞吐量,指的是某个并发用户下单位时间内处理的请求数。等效于QPS,其实可以看作同一个统计方式,只是叫法不同而已。
Time per request           -->用户平均请求等待时间
Time per request           -->服务器处理时间

原文地址:https://www.cnblogs.com/huanglingfa/p/13775796.html