Linux中提供了一个比较实用的压测工具ab,主要用于对web站点做压力测试,下面是它们的安装以及使用方法
1、安装ab
yum -y install httpd-tools
查看是否安装成功
2、基本常用参数说明
-n :请求总次数
-c:并发数
-k:是否开启长连接
-s:超时设置
-t:请求时间
3、使用方法
例:请求百度网站https://www.baidu.com/ 100次,并发100个,请求时间10秒
[root@instance-6id7j080 ~]# ab -c 100 -n 100 -t 10 https://www.baidu.com/This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking www.baidu.com (be patient)Completed 5000 requestsFinished 6318 requestsServer Software: BWS/1.1Server Hostname: www.baidu.comServer Port: 443SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128Document Path: /Document Length: 227 bytesConcurrency Level: 100 并发数Time taken for tests: 10.001 seconds 总耗时Complete requests: 6318 成功请求数Failed requests: 0 失败请求数Write errors: 0Total transferred: 5641974 bytesHTML transferred: 1434186 bytesRequests per second: 631.73 [#/sec] (mean) 即每秒的响应请求数,也即是最大吞吐能力(qps)总请求数/总耗时Time per request: 158.296 [ms] (mean) 客户端发出请求到收到响应,单个请求所耗费的时间Time per request: 1.583 [ms] (mean, across all concurrent requests) 表示服务端处理单个请求所耗费的时间Transfer rate: 550.91 [Kbytes/sec] received 传输速率Connection Times (ms) min mean[+/-sd] median maxConnect: 5 122 487.2 12 7027Processing: 2 12 31.8 5 1004Waiting: 2 11 31.2 4 1004Total: 7 133 488.6 18 7033Percentage of the requests served within a certain time (ms) 50% 18 66% 23 75% 30 80% 60 90% 216 95% 1014 98% 1217 99% 3023 100% 7033 (longest request)
以上就是ab对web站点压测使用方法。