ApacheBench
ab是apacheBench的缩写,是一个单线程命令,是Apache服务器自带的一个web压力测试工具,最初是用于测试Apache HTTP Server。使用时,ab命令会创建并发访问线程,模拟多个访问者同时对某一个URL地址进行访问。
安装
yum -y install httpd-tools
使用的方法:
ab [option] [http://]host[:port]/path
其中[option]是ab命令提供的可选参数,常用的参数:
-n 指定压力测试总共访问页面的次数,默认是1
-c 用于一次产生请求的并发数,默认是1
应用
测试IP地址为192.168.153.185上的web服务
[root@localhost ~]# ab -c 200 -n 10000 http://192.168.153.185/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.153.185 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.18.0
Server Hostname: 192.168.153.185
Server Port: 80
Document Path: /
Document Length: 612 bytes
Concurrency Level: 200
Time taken for tests: 3.133 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 8450000 bytes
HTML transferred: 6120000 bytes
Requests per second: 3191.77 [#/sec] (mean)
Time per request: 62.661 [ms] (mean)
Time per request: 0.313 [ms] (mean, across all concurrent requests)
Transfer rate: 2633.83 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 21 82.3 12 1032
Processing: 4 31 35.7 25 858
Waiting: 4 30 35.6 24 858
Total: 10 52 91.2 40 1236
Percentage of the requests served within a certain time (ms)
50% 40
66% 46
75% 51
80% 54
90% 66
95% 91
98% 212
99% 264
100% 1236 (longest request)
[root@localhost ~]#