安装
sudo yum -y install httpd-tools
测试
# 一共1000次请求,总共通过100个客户端(也就是并发数为:100)
ab -n 1000 -c 100 https://www.baidu.com/
结果
# bsw 类似 nginx
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: 100
# 整个测试总耗时
Time taken for tests: 16.315 seconds
# 完成请求
Complete requests: 1000 Failed requests: 0 Write errors: 0
Total: 1081903 bytes
HTML transferred: 227000 bytes
# QPS:每秒处理请求数
Requests per second: 61.29 [#/sec] (mean)
# 完成一个请求所需时间
Time per request: 1631.463 [ms] (mean)
Time per request: 16.315 [ms] (mean, across all concurrent requests)
Transfer rate: 64.76 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 21 604 1164.1 86 6922
Processing: 7 181 629.2 9 6939
Waiting: 7 181 629.2 9 6939
Total: 29 785 1379.1 240 13842
Percentage of the requests served within a certain time (ms)
50% 240
66% 867
75% 1038
80% 1102
90% 1908
95% 3578
98% 6724
99% 6922
100% 13842 (longest request)
查看系统负载情况
# id表示:剩余可用cpu数,低于40%就会卡
top - 17:59:18 up 36 days, 20:29, 6 users, load average: 0.01, 0.04, 0.05
Tasks: 116 total, 1 running, 113 sleeping, 2 stopped, 0 zombie
%Cpu(s): 1.0 us, 1.0 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1882232 total, 260580 free, 783692 used, 837960 buff/cache
KiB Swap: 1049596 total, 1049596 free, 0 used. 836048 avail Mem