博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
压力测试工具Siege安装与使用
阅读量:6856 次
发布时间:2019-06-26

本文共 3948 字,大约阅读时间需要 13 分钟。

hot3.png

Siege 是Linux/Unix下的一个WEB系统的压力测试工具。

下载与安装:

下载地址: 目前最新版本是 2016-05-20 发布的 siege-4.0.2.tar.gz

$ wget http://download.joedog.org/siege/siege-latest.tar.gz$ tar zxf siege-latest.tar.gz$ cd siege-4.0.2/$ ./configure$ sudo make$ sudo make install

查看是否安装成功:

查看siege安装路径:$ which siege/usr/local/bin/siege查看siege版本:$ siege -VSIEGE 4.0.2

参数说明:

可以使用"siege -h"命令来查看帮助信息:

$ siege -hSIEGE 4.0.2Usage: siege [options]       siege [options] URL       siege -g URLOptions:  -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  -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
查看当前的配置信息$ siege -C

使用说明:

(1) 直接请求URL:

$ siege -c 20 -r 10 http://www.cnwytnet.com

参数说明: -c 是并发量,并发数为20人 -r 是重复次数, 重复10次

(2) 随机选取urls.txt中列出所有的网址

在当前目录下创建一个名为"urls-demo.txt"的文件。 文件里边填写URL地址,可以有多条,每行一条,比如:

# URLs:http://www.sogou.com/web?query=php&from=wang_yong_taohttps://www.baidu.com/

// 执行 $ siege -c 5 -r 10 -f urls-demo.txt $ siege -c 5 -r 10 -f /Users/WangYoungTom/temp/urls-demo.txt

参数说明: -c 是并发量,并发数为5人 -r 是重复次数, 重复10次 -f 指定使用文件,urls-demo.txt就是一个文本文件,每行都是一个url,会从里面随机访问的

Siege从Siege-V2.06起支持POST和GET两种请求方式。 如果想模拟POST请求,可以在urls-demo.txt中安装一下格式填写URL:

# URL (POST):http://wangtest.com/index.php POST UserId=XXX&StartIndex=0&OS=Android&Sign=cff6wyt505wyt4chttp://wangtest.com/articles.php POST UserId=XXX&StartIndex=0&OS=iOS&Sign=cff63w5905wyt4c

使用示例:

// 请求http://www.cnwytnet.com,并发人数为10,重复5次,每次请求间隔3秒$ siege --concurrent=10 --reps=5 --delay=3 http://www.cnwytnet.com$ siege -c 10 -r 5 -d 3 http://www.cnwytnet.com

结果说明:

Transactions: 153 hits (处理次数,本次处理了153此请求)

Availability: 100.00 % (可用性/成功次数的百分比,比如本次100%成功)
Elapsed time: 17.22 secs (运行时间,本次总消耗17.22秒)
Data transferred: 7.70 MB (数据传送量)
Response time: 0.17 secs (响应时间)
Transaction rate: 8.89 trans/sec (处理请求频率,每秒钟处理8.89次请求)
Throughput: 0.45 MB/sec (吞吐量,传输速度)
Concurrency: 1.54 (实际最高并发连接数)
Successful transactions: 153 (成功的传输次数)
Failed transactions: 0 (失败的传输次数)
Longest transaction: 0.70 (处理传输是所花的最长时间)
Shortest transaction: 0.02 (处理传输是所花的最短时间)

使用实例:

$ siege -c 5 -r 10 http://www.baidu.comTransactions:                386 hitsAvailability:             100.00 %Elapsed time:              37.40 secsData transferred:          19.47 MBResponse time:              0.43 secsTransaction rate:          10.32 trans/secThroughput:             0.52 MB/secConcurrency:                4.45Successful transactions:         386Failed transactions:               0Longest transaction:            2.38Shortest transaction:           0.02

参考链接:

官网

文档

更新记录:

  1. 20160908 整理本文内容
  2. 20160909 新增整理POST请求内容

[END]

转载于:https://my.oschina.net/wangyongtao/blog/744448

你可能感兴趣的文章
C#之类与对象知识点
查看>>
斯坦福大学公开课机器学习:Neural network-model representation(神经网络模型及神经单元的理解)...
查看>>
七、集成swagger2
查看>>
Python(面向对象5——高级)
查看>>
chocolatey使用
查看>>
【转】iOS高级向的十道面试问题
查看>>
昂贵的聘礼 poj 1062 Dijkstra
查看>>
Hadoop HA的搭建
查看>>
JavaScript实现搜索框效果
查看>>
搭建nginx流媒体服务器(支持HLS)
查看>>
struts2上传文件大小受限问题
查看>>
dao使用JdbcTemplate(注入过程)视频学习
查看>>
无刷新URL 更新
查看>>
狮入羊口
查看>>
HDU 1421 搬寝室[DP]
查看>>
二层设备与三层设备的区别--总结
查看>>
ZOJ 3829 Known Notation(字符串处理 数学 牡丹江现场赛)
查看>>
JS操作css样式用法
查看>>
怎样使用 CCache 进行 cocos2d-x 编译加速
查看>>
Thymeleaf 3.0 专题
查看>>