Web性能压力测试工具——Siege

2023-04-28,,

  最近需要对Istio里的bookinfo进行分析,老是手去刷新太慢了,就找了个自动点的工具——Siege

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

  Siege官网:http://www.joedog.org/

安装siege

apt-get install siege

Siege命令常用参数

-c    //指定并发数200
-r //指定测试的次数5
-f //urls.txt 制定url的文件
-i //internet系统,随机发送url
-b //请求无需等待 delay=0
-t //持续测试5分钟
//-r和-t一般不同时使用

urls.txt位于  /etc/siege/ 文件夹下,它的格式

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

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

常用的siege命令举例

//200个并发对http://www.google.com发送请求100次
siege -c -r http://www.google.com //对urls.txt中的所有网址进行测试
siege -c -r -f urls.txt //随机选取urls.txt中列出的网址进行测试
siege -c -r -f urls.txt -i //delay=0,更准确的压力测试,而不是功能测试
siege -c -r -f urls.txt -i -b //指定http请求头 文档类型
siege -H "Content-Type:application/json" -c -r -f urls.txt -i -b

Siege输出结果说明

** SIEGE 2.72
** Preparing concurrent users for battle.
The server is now under siege..      done. Transactions:                 hits //已完成的事务总署
Availability:              100.00 %   //完成的成功率
Elapsed time:                0.08 secs   //总共使用的时间
Data transferred:            0.94 MB   //响应中数据的总大小
Response time:                0.00 secs   //显示网络连接的速度
Transaction rate:         3750.00 trans/sec  //平均每秒完成的事务数
Throughput:               11.79 MB/sec   //平均每秒传送的数据量
Concurrency:                8.50   //实际最高并发链接数
Successful transactions:           //成功处理的次数
Failed transactions:                   //失败处理的次数
Longest transaction:            0.01   //最长事务处理的时间
Shortest transaction:            0.00   //最短事务处理时间

此外还可以看siege的日志

vi /var/log/siege.log

Web性能压力测试工具——Siege的相关教程结束。

《Web性能压力测试工具——Siege.doc》

下载本文的Word格式文档,以方便收藏与打印。