LoginSignup
2
1

More than 5 years have passed since last update.

負荷テストツールSiegeを使ってみた

Posted at

// 本家ドキュメント
https://www.joedog.org/siege-manual/

siege install


# centos
sudo yum install -y openssl-devel zlib-devel make gcc

# Debian系(ubuntuなど)
sudo apt-get install libssl-dev zlib1g-dev make gcc

mkdir /tmp/aaa && cd /tmp/aaa

# wget http://download.joedog.org/siege/siege-latest.tar.gz
wget http://download.joedog.org/siege/siege-4.0.4.tar.gz
tar zxvf ./siege-4.0.4.tar.gz
rm -f siege-4.0.4.tar.gz
cd siege-4.0.4/
./configure && make
sudo make install

# 確認
siege --help
SIEGE 4.0.4
Usage: siege [options]
       siege [options] URL
       siege -g URL
Options:
  -V, --version             VERSION, prints the version number.
  -h, --help                HELP, prints this section.
  -C, --config              CONFIGURATION, show the current 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.
  -p, --print               PRINT, like GET only it prints the entire page.
  -c, --concurrent=NUM      CONCURRENT users, default is 10
  -r, --reps=NUM            REPS, number of times to run the test.
  -t, --time=NUMm           TIMED testing where "m" is modifier S, M, or H
                            ex: --time=1H, one hour test.
  -d, --delay=NUM           Time DELAY, random delay before each requst
  -b, --benchmark           BENCHMARK: no delays between requests.
  -i, --internet            INTERNET user simulation, hits URLs randomly.
  -f, --file=FILE           FILE, select a specific URLS FILE.
  -R, --rc=FILE             RC, specify an siegerc file
  -l, --log[=FILE]          LOG to FILE. If FILE is not specified, the
                            default is used: PREFIX/var/siege.log
  -m, --mark="text"         MARK, mark the log file with a string.
                            between .001 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
      --no-parser           NO PARSER, turn off the HTML page parser
      --no-follow           NO FOLLOW, do not follow HTTP redirects

Copyright (C) 2017 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

何でも良いのでテスト用にWebサーバを立ち上げる


今回はNode.js製のサーバを使う(Node.jsとnpmがインストールされている必要がある)

# http-server install

npm install http-server
./node_modules/.bin/http-server -p 8080

useage


ディレイ(遅延)の指定が独特。

-d NUM
-delay = NUM
クライアントは、1とNUMの間の秒数だけランダムに遅延します。なので、 -d1 を指定すれば遅延無しです(ベンチのときはこれ。)

各クライアントで、リクエストタイミングをずらしたい場合は、2以上の数を指定します。デフォルトは3です。

# ディレイが1(遅延しない)で、20クライアント、5秒間リクエストしつづける
siege 127.0.0.1:8080 -d1 -c20 -t5S

Lifting the server siege...
Transactions:                191 hits
Availability:             100.00 %
Elapsed time:               4.53 secs
Data transferred:          12.08 MB
Response time:              0.01 secs
Transaction rate:          42.16 trans/sec
Throughput:             2.67 MB/sec
Concurrency:                0.34
Successful transactions:         191
Failed transactions:               0
Longest transaction:            0.03
Shortest transaction:           0.00

# ディレイは1秒から3秒の間どれかでランダム遅延して、20クライアント、10リクエスト投げる
siege 127.0.0.1:8080 -d3 -c20 -r10

Transactions:                200 hits
Availability:             100.00 %
Elapsed time:               9.09 secs
Data transferred:          12.65 MB
Response time:              0.01 secs
Transaction rate:          22.00 trans/sec
Throughput:             1.39 MB/sec
Concurrency:                0.19
Successful transactions:         200
Failed transactions:               0
Longest transaction:            0.04
Shortest transaction:           0.00

file useage



echo 127.0.0.1:8080 > aaa.txt

# ファイルに指定したURLに対して、ディレイ無し、クライアント10、10秒間リクエストを投げる
siege -f aaa.txt -d1 -c10 --time=10S

### -------------------------------------------------------------

# URLの指定は、こんな感じで、POSTでパラメータ指定も出来る
http://127.0.0.1/cgi-bin/hello.pl POST name=homer

# ファイル指定だと変数も使える
HOGE=https://eos.joedog.org
$(HOGE)/siege/index.php

nohup useage



# SSHが閉じても実行する。一日とか実行したい場合は、下記
nohup sh -c 'siege 127.0.0.1:8080 -d1 -c10 --time=24H' > /tmp/bbb.log &

とりあえず書いてみました。変更もあると思うので、基本はドキュメント見てほしいです。
(参考にしたサイトのやつも、パラメータ指定の仕方が若干変わっていたみたいでした)

クライアント数を増やしたい場合、実行時にコンフィグファイルが出来るので、中のlimitを修正すると良いみたいです。

~/.siege/siege.conf

何かあっても丁寧なエラーが出るので、ちゃんと読んで実行していけばわかりやすいツールだと思いました。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1