apache bench安装apache
yum install -y httpd-tools
ab 的使用方法并发
# 最简单使用: -c concurrency 并发数; -n requests 请求数量 ab -n 10000 -c 100 ${target_url} # post 请求: -p 指定须要 post 的数据文件, -T 指定 content-type ab -n 10000 -c 100 -p params.file -T 'application/x-www-form-urlencoded' ${target_url} # -s: timeout, 单位为秒 ab -n 10000 -c 100 -s 20 ${target_url} # -t: timelimit, 指定本次压测的最长时间限制 # 若是不指定 -n, 这里还会默认指定一个 -n 50000 ab -c 100 -s 20 -t 60000 ${target_url} # -r: 当发生 socket error 时不退出, 而是继续执行请求 # -k: 在 http 请求的 headers 中加上 Connection: keep-alive, 以保持链接 ab -n 10000 -c 100 -r -k ${target_url} # 将压测数据记录为 gunplot 能够分析的 dump 文件, 以供其渲染 ab -n 10000 -c 100 -g data.plt ${target_url}