Siege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the internet. Siege supports basic authentication, cookies, HTTP and HTTPS protocols. It lets its user hit a web server with a configurable number of simulated web browsers. Those browsers place the server “under siege.”




wget http://www.joedog.org/pub/siege/siege-latest.tar.gz

tar zxvf siege-latest.tar.gz
cd siege-3.0.5/
sudo make install


zhou@zhou-VirtualBox:~$ siege --help
SIEGE 3.0.5
Usage: siege [options]
       siege [options] URL
       siege -g URL
  -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.
  -c, --concurrent=NUM      CONCURRENT users, default is 10
  -i, --internet            INTERNET user simulation, hits URLs randomly.
  -b, --benchmark           BENCHMARK: no delays between requests.
  -t, --time=NUMm           TIMED testing where "m" is modifier S, M, or H
                            ex: --time=1H, one hour test.
  -r, --reps=NUM            REPS, number of times to run the test.
  -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.
  -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

Copyright (C) 2013 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


-c 200       指定并发数200
-r 5         指定测试的次数5
-f urls.txt  指定url的文件
-i           模拟用户请求,随机选择url文件中的url
-b           请求之间没有延时
-t 30S       持续测试30
# -r和-t一般不同时使用


  • 50个用户(每次并发量,注意不是每秒并发量)重复100次,共产生 50 * 100 = 5000个请求

    siege -c 50 -r 100 http://www.abc.com/

  • 50个用户,重复100次,发送GET参数

    siege -c 50 -r 100 https://www.abc.com/a.php?name=zhangsan

  • 50个用户,重复100次,发送POST参数 (注意引号)

    siege -c 50 -r 100 “https://www.abc.com/a.php POST name=zhangsan”

  • 50个用户,重复100次,发送POST参数(从文件中读取)

    siege -c 50 -r 100 “https://www.abc.com/a.php POST < /root/ab_test/post.xml”

  • 在urls.txt中列出所有的网址(urls.txt格式为每行一个url)

    siege -c 200 -r 100 -f urls.txt

  • 随机选取urls.txt中列出所有的网址

    siege -c 200 -r 100 -f urls.txt -i

  • delay=0,更准确的压力测试,而不是功能测试

    siege -c 200 -r 100 -f urls.txt -i -b

  • 指定http请求头 文档类型

    siege -H “Content-Type:application/json” -c 200 -r 100 -f urls.txt -i -b


zhou@zhou-VirtualBox:~$ siege -c 500 -t 30s http://localhost:3000/

Lifting the server siege...      done.

Transactions:               12561 hits      // 完成12561次请求
Availability:              100.00 %         // 成功率100%
Elapsed time:               30.03 secs      // 执行时间:30.03秒
Data transferred:            2.47 MB        // 共传输数据2.47MB
Response time:                0.58 secs      // 响应时间0.58秒
Transaction rate:          418.28 trans/sec // 平均每秒完成请求418.28次
Throughput:                0.08 MB/sec        // 平均每秒数据传输量为0.08MB
Concurrency:              243.79           // 实际最高并发连接数
Successful transactions:       12561       // 成功处理次数
Failed transactions:               0       // 失败处理次数
Longest transaction:            1.58       // 最长请求耗时
Shortest transaction:            0.00       // 最短请求耗时


  • 如果url中含有空格和中文,要先进行url编码,否则siege发送的请求url不准确。