Created
September 13, 2016 06:45
-
-
Save pygman/702488826f2c0687906aa12a2139170d to your computer and use it in GitHub Desktop.
ApacheBench ab 压测
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 常用命令参数如下: -n 测试的请求数量 -c 同时请求数量(并发数) -t 测试时间 以上一般搭配 -n & -c 或者 -n & -t -k HTTP保持Keep-Alive方式(长连接) -p POST方式下发送的数据 -T POST或PUT方式下的Content-type | |
# 从常用命令参数中,我们用案例说话: a. 同时10个请求,连续点击1000次(每次Request完毕自动销毁,重新请求) | |
``` | |
ab -n 1000 -c 10 http://www.test.com/index.html | |
``` | |
# b. 同时10个请求,连续点击1000次,并保持Keep-Alive方式(保持长连接的方式) | |
``` | |
ab -n 1000 -c 10 -k http://www.test.com/index.html | |
``` | |
# c. 同时10个请求,请求测试时间为20s | |
``` | |
ab -c 10 -t 20 http://www.test.com/index.html | |
``` | |
# d. 将请求性能详情输出到CSV档文件 | |
``` | |
ab -e output.csv -n 1000 -c 10 http://www.test.com/index.html | |
``` | |
# out.csv: {请求序号 - 请求耗时ms} e. 包含Post的数据的文件,例如POST发送JSON格式数据 | |
``` | |
ab -p p.json -T application/json -n 1000 -c 10 http://www.test.com/index.html | |
``` | |
# p.json: | |
# {"mallId" : 1, "itemIds" : [9102,9101]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment