压测工具 siege 使用

ABOUT SIEGE

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, HTTPS and FTP protocols. It lets its user hit a server with a configurable number of simulated clients. Those clients place the server “under siege.”

官网

说了一堆,为啥不用 ab 或 flood 呢? 因为那俩玩意我都没编译成功 https,这个搞定了。

编译安装

wget -c http://download.joedog.org/siege/siege-3.1.4.tar.gz
tar zxvf  siege-3.1.4.tar.gz
 cd siege-3.1.4
./configure --prefix=/usr/local/siege --with-ssl=/usr/include/openssl/
make && make install

使用

常用的参数:

-c 200 并发200个用户
-r 150 重复循环150次
-f file 任务的URL列表

其它实用参数:

-i 随机 URL ,默认是从列表的上面到下面来打压力
-b 进行压力测试,不进行延时
-t 持续时间,即测试持续时间,在NUM时间后结束,单位默认为分

测试1:指定列表

./siege -c 200 -r 10 -f /opt/24k  -b -i

结果

HTTP/1.1 200   0.30 secs:    9604 bytes ==> GET  /post/48192.html
HTTP/1.1 200   0.29 secs:    9604 bytes ==> GET  /post/48192.html
HTTP/1.1 200   0.29 secs:    9604 bytes ==> GET  /post/48192.html
HTTP/1.1 200   0.29 secs:    9604 bytes ==> GET  /post/48192.html
done.

Transactions:                2000 hits
Availability:              100.00 %
Elapsed time:               24.26 secs
Data transferred:           18.32 MB
Response time:                2.28 secs
Transaction rate:           82.44 trans/sec
Throughput:                0.76 MB/sec
Concurrency:              187.81
Successful transactions:        2000
Failed transactions:               0
Longest transaction:            7.41
Shortest transaction:            0.26

LOG FILE: /usr/local/siege/var/siege.log
You can disable this log file notification by editing
/root/.siege/siege.conf and changing 'show-logfile' to false.

测试2 :直接给定 url

./siege -c 200 -r 10 -b https://awen.me