ab的安装
1.源码安装apache
apache安装完毕后ab命令存放在apache安装目录的bin目录下。
2.yum安装apache
如果apache 是通过yum的RPM包方式安装的话,ab命令默认存放在/usr/bin目录下
3.没有安装apache直接安装ab
如果不想安装apache但是又想使用ab命令的话,我们可以直接安装apache的工具包httpd-tools
yum -y install httpd-tools
ab的使用
-c 表示 并发用户数
-n表示 总请求数
[root@cobbler bin]# ab -c3 -n30 https://10.207.200.100/main/index/index
This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 10.207.200.100 (be patient).....doneServer Software: Apache/2.2.15Server Hostname: 10.207.200.100Server Port: 443SSL/TLS Protocol: TLSv1/SSLv3,ECDHE-RSA-AES256-GCM-SHA384,2048,256Document Path: /main/index/indexDocument Length: 295 bytesConcurrency Level: 3Time taken for tests: 0.232 secondsComplete requests: 30Failed requests: 0Write errors: 0Non-2xx responses: 30Total transferred: 14250 bytesHTML transferred: 8850 bytesRequests per second: 129.59 [#/sec] (mean)
Time per request: 23.150 [ms] (mean)Time per request: 7.717 [ms] (mean, across all concurrent requests)Transfer rate: 60.11 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 12 19 7.6 16 42Processing: 0 2 2.4 1 10Waiting: 0 1 1.0 1 5Total: 12 21 8.9 17 52Percentage of the requests served within a certain time (ms) 50% 17 #50%的请求在17S完成 66% 21 #66%的请求在21S完成 75% 22 80% 27 90% 34 95% 36 98% 52 99% 52 100% 52 (longest request)
(1)Requests per second吞吐率
服务器并发处理能力的量化描述,单位是reqs/s,指的是在某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率。
计算公式:Complete requests/Time taken for tests
(2)Time per request用户平均请求等待时间
计算公式:Time token for tests/(Complete requests/Concurrency Level)。
(3)Time per requet(across all concurrent request)服务器平均请求等待时间
计算公式:Time taken for tests/Complete requests,正好是吞吐率的倒数。