壓力測試工具 ab

apache bench安裝

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}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章