压力测试siege

 

siege是一款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。


安装:
官网下载siege-4.0.4.tar.gz:https://www.joedog.org/siege-faq/

 

tar -xvfsiege-4.0.4.tar.gz
cd siege-4.0.4
./configure
make
make install
siege –version


输出:
SIEGE 4.0.4
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.
证明安装成功。

 

 

Get请求测试:

siege -c 100 -r 10 http://www.google.com


Post请求测试:

 

siege -c 100 -r 10 ' http://www.google.com:8005/pressure POST <./1.default'

siege的json请求,需要使用&将每个参数分割开

例如,1.default的格式如下,project_name, post_file, file_name , request_parm ,md5等字段之间使用&连接,赋值使用key=value的方式

project_name=ks_scan_ocr&post_file=%2F9j%2F4R%2Bhsde%2F1%2Ffuvde9%2B691%2F%2F9k%3D&file_name=test.png&request_parm=None&md5=34564d646b5014f0a35daf1c9182996c&request_type=9&check_md5=True

测试脚本,

#!/bin/bash
concurrent=40
reps=4
pool=("10.default")
num=${#pool[*]}
postfile=${pool[$((RANDOM%num))]}
echo ${jsonfile}
siege -c ${concurrent} -r ${reps} 'http://120.92.114.84:8112/api POST <'''${postfile}''''

 

接口参数解释:
-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]




结果参数:
Transactions: 30000 hits //完成30000次处理
Availability: 100.00 % //100.00 % 成功率
Elapsed time: 68.59 secs //总共使用时间
Data transferred: 817.76 MB //共数据传输 817.76 MB
Response time: 0.04 secs //响应时间,显示网络连接的速度
Transaction rate: 437.38 trans/sec //平均每秒完成 437.38 次处理
Throughput: 11.92 MB/sec //平均每秒传送数据
Concurrency: 17.53 //实际最高并发连接数
Successful transactions: 30000 //成功处理次数
Failed transactions: 0 //失败处理次数
Longest transaction: 3.12 //每次传输所花最长时间
Shortest transaction: 0.00 //每次传输所花最短时间

 

 

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很好用的网络压力测试工具 Linux版 siege的安装 unzip filename.zip cd siege-*.*.* ./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/ssl mkdir -p /usr/local/siege/etc mkdir -p /usr/local/siege/var make make install 查看配置文件 /usr/local/siege/bin/siege -C 二、siege的使用 举例说明: 50个用户(每次并发量)重复100次 共产生 50*100 个请求 /usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com 50个用户 重复100次 发送GET参数 /usr/local/siege/bin/siege -c 50 -r 100 http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=60 50个用户 重复100次 发送POST参数 (注意引号) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST name=zhangsan" 50个用户 重复100次 发送POST参数(从文件中读取) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST < /root/ab_test/post.xml" 另外还有挺多参数 详情请man 或 siege -h siege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。 Transactions: 10 hits :服务器接收的请求数 Availability: 100.00 % :有效情况的比例 Elapsed time: 1.06 secs : 测试所用的时间 Data transferred: 0.04 MB :每个模拟用户的数据传输量 Response time: 0.03 secs :响应每个模拟用户请求的平均时间 Transaction rate: 9.43 trans/sec :服务器每秒处理事务的平均数 Throughput: 0.04 MB/sec :服务器每秒跟所有模拟用户的数据传输量 Concurrency: 0.25 :每秒的模拟连接 Successful transactions: 10 :处理成功的事务数(code<400) Failed transactions: 0 : 处理失败的事务数(code>400) Longest transaction: 0.04 :最长的事务处理时间 Shortest transaction: 0.02 :最短的事务处理时间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值