siege 性能测试手记(一)

    技术2025-06-19  17

    siege 工具安装过程

     

    yum install gcc

    http://www.joedog.org/index/siege-manual

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

    tar -vxzf siege-latest.tar.gz

    cd siege-2.69/

    ./configure

    make

    make install

     

    vi /etc/hosts127.0.0.1 localhost192.168.100.38 dev.google.com

    ping dev.google.com

    mkdir /usr/local/var/

    vi 在/usr/local/var/下新建保存一个文件siege.log

    cat /usr/local/var/siege.log

    siege -d1 -c200 -r100  http://dev.google.com/producttags/A/

    siege -d1 -c200 -r100  -f /root/abc.txt

     

    ******Putty 连接参数******host name:192.168.146.129 port:22connetion type:sshload sessions:192.168.146.129close window on exit: only on clean exitlogin: rootpassword: 2010

     

     -----------------------------------------------------------测试环境

     

    CPU:intel 四核

    Memory:4G

    Network=1Gbs

    Hard Disk=10000转/分钟

    OP=CentOS Linux

    WinSCP

    putty.exe

    Siege

    ------------------------------------------------------------ Siege Help

     

    [root@localhost var]# siege --helpSIEGE 2.69Usage: siege [options]       siege [options] URL       siege -g URLOptions:  -V, --version           VERSION, prints version number to screen.  -h, --help              HELP, prints this section.  -C, --config            CONFIGURATION, show the current configuration.  -v, --verbose           VERBOSE, prints notification to screen.  -g, --get               GET, pull down headers from the server and display HTTP                          transaction. Great for web application debugging.  -c, --concurrent=NUM    CONCURRENT users, default is 10  -u, --url="URL"         Deprecated. Set URL as the last argument.  -i, --internet          INTERNET user simulation, hits the URLs randomly.  -b, --benchmark         BENCHMARK, signifies no delay for time testing.  -t, --time=NUMm         TIME based testing where "m" is the modifier S, M, or H                          no space between NUM and "m", ex: --time=1H, one hour test.  -r, --reps=NUM          REPS, number of times to run the test, default is 25  -f, --file=FILE         FILE, change the configuration file to file.  -R, --rc=FILE           RC, change the siegerc file to file.  Overrides                          the SIEGERC environmental variable.  -l, --log               LOG, logs the transaction to PREFIX/var/siege.log  -m, --mark="text"       MARK, mark the log file with a string separator.  -d, --delay=NUM         Time DELAY, random delay between 1 and num designed                          to simulate human activity. Default value is 3  -H, --header="text"     Add a header to request (can be many)  -A, --user-agent="text" Sets User-Agent in request

     

     

    ------------------------------------------------------------Test Result

     

    Lifting the server siege...      done.                                        

    Transactions:                       0 hitsAvailability:                   0.00 %Elapsed time:                  15.36 secsData transferred:               0.00 MBResponse time:                  0.00 secsTransaction rate:               0.00 trans/secThroughput:                     0.00 MB/secConcurrency:                    0.00Successful transactions:        0Failed transactions:               0Longest transaction:            0.00Shortest transaction:           0.00

    FILE: /usr/local/var/siege.logYou can disable this annoying message by editingthe .siegerc file in your home directory; changethe directive 'show-logfile' to false.

     

    ------------------------------------------------------------Siege -- 压力测试工具

    Siege是一个多线程的WEB性能测试工具,被设计成可以让WEB开发人员了解代码在长时间压力下的性能.可以模拟很多用户同时访问WEB服务器,此数量可以自由定义.这就相当于web server被围攻(siege)了.

    性能指标包括已用时间(elapsed time),总数据传输量(total data transferred),服务器响应时间 (response time),执行率?(transaction rate),并发数(concurrency),每次运行后会生成报告.

     

    siege有三种运行模式:regression,internet simulation,brute force(我们最常用的是internet simulation,模拟用户对网站访问的随机性)

     

    ==== 选项如下: ====''-C,或--config''

    在屏幕上打印显示出当前的配置,配置是包括在他的配置文件$HOME/.siegerc中,可以编辑里面的参数,这样每次siege都会按照它运行.

    ''-v''

    运行时能看到详细的运行信息

    ''-c n,或--concurrent=n''

    模拟有n个用户在同时访问,n不要设得太大,因为越大,siege消耗本地机器的资源越多

    ''-i,--internet''

    随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性),当urls.txt存在是有效

    ''-d n,--delay=n''

    hit每个url之间的延迟,在0-n之间

    -r n,--reps=n

    重复运行测试n次,不能与 -t同时存在

    -t n,--time=n

    持续运行siege'n'秒(如10S),分钟(10M),小时(10H)

    -l

    运行结束,将统计数据保存到日志文件中siege.log,一般位于/usr/local/var/siege.log中,也可在.siegerc中自定义

    -R SIEGERC,--rc=SIEGERC

    指定用特定的siege配置文件来运行,默认的为$HOME/.siegerc

    -f FILE, --file=FILE

    指定用特定的urls文件运行siege,默认为urls.txt,位于siege安装目录下的etc/urls.txt

    -u URL,--url=URL

    测试指定的一个URL,对它进行"siege",此选项会忽略有关urls文件的设定

    urls.txt文件:

    是很多行待测试URL的列表以换行符断开,格式为:

    [protocol://]host.domain.com[:port][path/to/file]

     

    例如:

    http://www.telltruth.net/wiki/index.phphttp://www.telltruth.net/index.htmlhttp://www.telltruth.net/gallerywww.telltruth.net/blog

    Example:

    siege -c 100 -t30M -u http://telltruth.net/

    表示对http://telltruth.net/这个站点使用100个用户并发访问,持续30分钟进行测试注意:"-t30M"之间没有空格

    关于作者:siege的作者:Jeffrey Fulmer <jeff@joedog.org>官方主页:joedog.org

    ==== 安装 ====

    freebsd:<code>pkg_add -r siege</code>或者使用ports:<code>cd /usr/ports/benchmarks/siegemakemake install</code>gentoo:<code>emerge siege</code>

     

    ==== .siegerc中几个重要的选项 ====

    internet = true | false

    true表示对urls.txt中的URL随机访问,以模拟实际的Internet;false表示按urls.txt中的URL列表顺序访问

    logging = true|false

    选择是否记录结果到日志中

    logfile = /home/maxim/log/siege.log

    运行结果日志的保存位置

    protocol = HTTP/1.0 | HTTP/1.1

    选择协议的类型

    concurrent = 80

    设定有多少用户并发访问time = n(S|M|H)

    持续"siege"多长时间,可以秒,分钟,小时为单位file = /path/to/urls.txt

    设定默认的urls.txt文件位置,使用此选项须确保""url = xxx""无效(注释掉即可)

    url = http://xxx.xxx.xxx

    只针对某个url进行测试,此选项会使urls.txt的设定无效(-f URLSFILE)

    此外,siege还支持很多其他的功能,可以通过proxy测试,也可以测试需要用户身份认证的网页

    使用样例: 任务列表:www.chedong.com.url文件http://www.chedong.com/tech/http://www.chedong.com/tech/acdsee.htmlhttp://www.chedong.com/tech/ant.htmlhttp://www.chedong.com/tech/apache_install.htmlhttp://www.chedong.com/tech/awstats.htmlhttp://www.chedong.com/tech/cache.htmlhttp://www.chedong.com/tech/click.htmlhttp://www.chedong.com/tech/cms.htmlhttp://www.chedong.com/tech/compress.htmlhttp://www.chedong.com/tech/cvs_card.htmlhttp://www.chedong.com/tech/default.htmlhttp://www.chedong.com/tech/dev.htmlhttp://www.chedong.com/tech/gnu.html....

    siege -c 20 -r 2 -f www.chedong.com.url 参数说明: -c 20 并发20个用户 -r 2 重复循环2次 -f www.chedong.com.url 任务列表:URL列表

    输出样例:

    ** Siege 2.59** Preparing 20 concurrent users for battle. 这次“战斗”准备了20个并发用户 The server is now under siege.. done. 服务在“围攻”测试中: Transactions: 40 hits 完成40次处理 Availability: 100.00 % 成功率 Elapsed time: 7.67 secs 总共用时Data transferred: 877340 bytes 共数据传输:877340字节Response time: 1.65 secs 相应用时1.65秒:显示网络连接的速度Transaction rate: 5.22 trans/sec 平均每秒完成5.22次处理:表示服务器后台处理的速度Throughput: 114385.92 bytes/sec 平均每秒传送数据:114385.92字节Concurrency: 8.59 最高并发数 8.59Successful transactions: 40 成功处理次数Failed transactions: 0 失败处理次数

    注意:由于速度很快,可能会达不到并发速度很高就已经完成。Response time显示的是测试机器和被测试服务器之间网络链接状况。Transaction rate则表示服务器端任务处理的完成速度。

    辅助工具: 增量压力测试:

    为了方便增量压力测试,siege还包含了一些辅助工具:bombardment (1) 是一个辅助工具:用于按照增量用户压力测试: 使用样例: bombardment urlfile.txt 5 3 4 1初始化URL列表:urlfile.txt初始化为:5个用户 每次增加:3个用户 运行:4次 每个客户端之间的延迟为:1秒

    输出成CSV格式: siege2csv.pl (1) siege2csv.pl将bombardment的输出变成CSV格式: Time Data Transferred Response Time Transaction Rate Throughput Concurrency Code 200 (note that this is horribly broken.) 242 60.22 603064 0.02 4.02 10014.35 0.08605 59.98 1507660 0.01 10.09 25136.05 0.12938 59.98 2337496 0.02 15.64 38971.26 0.261157 60 2883244 0.04 19.28 48054.07 0.78

     

    最新回复(0)