Apache Benchの使い方

はじめに

Apache BenchvはWebサーバをベンチマークするためのツールです。この記事では、Apache Benchの簡単な使い方についてまとめます。

基本

abで利用します。ab -hで使い方が確認できます。

1
Usage: ab [options] [http[s]://]hostname[:port]/path

具体的には以下のように使います。

1
ab https://localhost:8000/

負荷をかける

負荷をかけたい場合はオプションを利用します。nが総リクエスト数、cが同時接続数を表します。n>=cである必要があります。

1
2
-n requests     Number of requests to perform
-c concurrency Number of multiple requests to make at a time
1
ab -n 20 -c 4 https://localhost:8000/

フォームのPOST

以下のようなテキストファイルを用意します。(param.txt)

1
username=hoge&password=fuga
1
ab -p param.txt -T "application/x-www-form-urlencoded" https://localhost:8000/login

参考

http://lapis25.hatenablog.com/entry/20070208/1170929622
https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data

記事情報

  • 投稿日:2020年6月23日
  • 最終更新日:2020年6月23日