2013年9月6日金曜日

Web負荷テスト: SIEGE



対象環境
Windows7(Cygwin 1.7)+SIEGE 3.0.3
CentOS 5.9+SIEGE 3.0.3


概要

コマンドラインで使う負荷テストツール。
特定URLに負荷を掛けるものが多い中、複数のURLに負荷を掛けることが可能。

LinuxベースなのでWindowsで使おうと思うとCygwinなどが必要。
Windows系で使える負荷テストツールは別途紹介するが、
コマンドより、GUIベースのものが便利。

インストール

以下サイトから、必要なファイルをダウンロード

siege
http://www.joedog.org/siege-home/


$ tar zxvf siege-latest.tar.gz
$ cd siege-3.0.3/
$ ./configure
$ make
$ make install


コマンド解説


コマンドの実行方法とオプションは以下


構文
siege [オプション] URL
siege -g URL


オプション

コマンド 説明
-V, --version バージョン表示
-h, --help ヘルプの表示
-C, --config 設定表示
-v, --verbose VERBOSE, prints notification to screen
-q, --quiet QUIET turns verbose off and suppresses output.
-g, --get GET, pull down HTTP headers and display the transaction. Great for application debugging.
-c, --concurrent=NUM 同時接続数(default 10)
-i, --internet URLのリストからランダムにリクエストを行なう
-b, --benchmark リクエストとリクエストの間に遅延を入れない
-t, --time=NUMm TIMED testing where "m" is modifier S, M, or H
-r, --reps=NUM コネクションあたりのリクエスト数
-f, --file=FILE URLを記述したファイル名
-R, --rc=FILE RC, specify an siegerc file
-l, --log[=FILE] ログファイル名
-m, --mark="text" MARK, mark the log file with a string.
-d, --delay=NUM Time DELAY, random delay before each requst between 1 and NUM. (NOT COUNTED IN STATS)
-H, --header="text" Add a header to request (can be many)
-A, --user-agent="text" Sets User-Agent in request
-T, --content-type="text" Sets Content-Type in request





実行サンプル


負荷を掛けるURLを列挙し、設定ファイルを作成する。

例) URLのリストを「CHECK.txt」として保存する
http://WEBSERVER/TEST1.html
http://WEBSERVER/TEST2.html
http://WEBSERVER/TEST3.html


例)
同時接続数を50
コネクション数を100
実行時間を1時間
URLリスト指定「CHECK.txt」
ログファイル指定「CHECK.log」

# siege --concurrent=50 --reps=100 --time=1H --internet --file=CHECK.txt --log=CHECK.log
[error] CONFIG conflict: selected time and repetition based testing: No such file or directory
defaulting to time-based testing: 3600 seconds
** SIEGE 3.0.3
** Preparing 50 concurrent users for battle.
The server is now under siege...
HTTP/1.1 404 0.19 1621 bytes ==> GET  /TEST1.html
HTTP/1.1 200   0.20 secs:    5483 bytes ==> GET  /TEST2.html
HTTP/1.1 200   0.20 secs:    2787 bytes ==> GET  /TEST3.html
HTTP/1.1 200   0.30 secs:    5483 bytes ==> GET  /TEST2.html
~省略~

Lifting the server siege...      done.

Transactions:                  14641 hits
Availability:                 100.00 %
Elapsed time:                 146.45 secs
Data transferred:             734.19 MB
Response time:                  0.00 secs
Transaction rate:              99.97 trans/sec
Throughput:                     5.01 MB/sec
Concurrency:                    0.31
Successful transactions:       14364
Failed transactions:               0
Longest transaction:            0.04
Shortest transaction:           0.00

FILE: CHECK.log
You can disable this annoying message by editing
the .siegerc file in your home directory; change
the directive 'show-logfile' to false.


ログファイル表示
      Date & Time,  Trans,  Elap Time,  Data Trans,  Resp Time,  Trans Rate,  Throughput,  Concurrent,    OKAY,   Failed
2013-09-06 18:18:13,     11,       9.03,           0,       0.06,        1.22,        0.00,        0.08,      10,       0
2013-09-06 18:20:40,    196,      99.12,          10,       0.04,        1.98,        0.10,        0.09,     193,       0



例)設定表示
#siege -C
CURRENT ; SIEGE ; CONFIGURATION
JoeDog/1.00 [en] (X11; I; Siege 3.0.3)
Edit the resource file to change the settings.
----------------------------------------------
version:                 3.0.3
verbose:                true
quiet:                    false
debug:                   false
protocol:                HTTP/1.1
get method:            HEAD
connection:             close
concurrent users:    15
time to run:            n/a
repetitions:             n/a
socket timeout:       30
accept-encoding:    gzip
delay:                   1 sec
internet simulation: false
benchmark mode:   false
failures until abort: 1024
named URL:          none
URLs file:              /usr/local/etc/urls.txt
logging:                  true
log file:                  /usr/local/var/siege.log
resource file:          /usr/local/etc/siegerc
timestamped output: false
comma separated output: false
allow redirects:       true
allow zero byte data: true
allow chunked encoding: true
upload unique files: true


例) POSTリクエストを送信する場合のパラメータファイルの書き方
http://127.0.0.1/users POST key1=value1&key2=value2





0 件のコメント:

コメントを投稿