记录一下最近了解的压力测试工具 ab 全称: apache bench


  • 测试命令:
    1
    ab -c 1000 -n 100 -p data.txt -T application/json -H "token:xxx" -w "http://127.0.0.1/test/" >> test.html

    -c: 请求数量
    -n: 请求并发量
    -p: 请求参数文件
    -T: Content-type
    -H: 追加一个请求头
    -w: 测试结果以html形式存储在test.html文件中, 不添加 -w 和 >> test.html 结果会打印在终端

-p 的参数文件内的参数格式是由Content-type决定的

参考: http://httpd.apache.org/docs/2.4/programs/ab.html