作者:cc辰辰cc小宝宝 | 来源:互联网 | 2023-05-16 11:11
概述AB(ApacheBench)用来做http的压力测试。ubuntu里安装ab测试工具sudoapt-getinstallapache2-utils测试命令最常用的测试
概述
AB(ApacheBench)用来做http的压力测试。
ubuntu里安装ab测试工具
sudo apt-get install apache2-utils
测试命令
最常用的测试命令如下:
ab -n 100 -c 10 http:
-n表示请求数,-c表示并发数
带自定义header请求:
ab -n 1 -c 1 -H "Pragma:no-cache" http:
-H带header请求
模拟post请求
ab -n 1 -c 1 -p 'post.txt' -T 'application/x-www-form-urlencoded' http:
-p 用来做post数据的文件,这里此文件保存在ab同级目录下
- T 设置content-type值
其它ab命令参数见官方网站.
测试结果分析
执行命令:
ab -n 100 -c 10 http://192.168.188.6:8080/distributeLock
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.188.6 (be patient).....done
Server Software:
Server Hostname: 192.168.188.6
Server Port: 8080
Document Path: /distributeLock
Document Length: 14 bytes
Concurrency Level: 10
Time taken for tests: 0.153 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 14700 bytes
HTML transferred: 1400 bytes
Requests per second: 652.40 [
Time per request: 15.328 [ms] (mean)
Time per request: 1.533 [ms] (mean, across all concurrent requests)
Transfer rate: 93.66 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 2.9 3 10
Processing: 3 11 7.0 9 65
Waiting: 3 8 6.7 7 65
Total: 6 15 7.0 14 68
Percentage of the requests served within a certain time (ms)
50% 14
66% 15
75% 16
80% 17
90% 20
95% 22
98% 32
99% 68
100% 68 (longest request)