前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >web网站压测工具Siege介绍

web网站压测工具Siege介绍

作者头像
小麦苗DBA宝典
发布2021-12-17 19:28:46
1.7K0
发布2021-12-17 19:28:46
举报

简介

Siege是一款高性能的、开源的Http压力测试工具,设计用于评估WEB应用在压力下的承受能力。Siege支持身份验证、cookies、http、https和ftp协议。可以根据配置,对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的响应时间,并在一定数量的并发访问下重复进行。

siege可以从您选择的预置列表中请求随机的URL,所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。

Siege支持多链接,支持get和post请求,可以对web系统进行多并发下持续请求的压力测试。

  • Siege官网:https://www.joedog.org/
  • Siege下载:http://download.joedog.org/siege/siege-latest.tar.gz
  • Github:https://github.com/JoeDog/siege

安装

解压并安装:

代码语言:javascript
复制
-- yum直接安装
yum install -y siege

-- 也可以编译安装
tar -zxvf siege-latest.tar.gz
cd siege-4.1.1
./configure --with-ssl=/usr/local/openssl
make && make install


[root@docker35 siege-4.1.1]# siege -h
New configuration template added to /root/.siege
Run siege -C to view the current settings in that file
SIEGE 4.1.1
Usage: siege [options]
       siege [options] URL
       siege -g URL
Options:
  -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.
  -p, --print               PRINT, like GET only it prints the entire page.
  -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 request
  -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
  -j, --json-output         JSON OUTPUT, print final stats to stdout as JSON
      --no-parser           NO PARSER, turn off the HTML page parser
      --no-follow           NO FOLLOW, do not follow HTTP redirects

Copyright (C) 2021 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.

参数详解:

  • -C,或--config 在屏幕上打印显示出当前的配置,配置是包括在配置文件$HOME/.siegerc中,可以编辑里面的参数,这样每次siege 都会按照它运行.
  • -v 运行时能看到详细的运行信息
  • -c n,或--concurrent=n 模拟有n个用户在同时访问,n不要设得太大,因为越大,siege 消耗本地机器的资源越多,并发用户数量,默认10个,注意:siege默认只支持255个并发数,可以自己自定义,修改/root/.siege/siege.conf下的limit数值。
  • -i,--internet 随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性),当urls.txt存在时有效,模拟网络用户随机点击URL
  • -d n,--delay=n hit每个url之间的延迟,在0-n之间
  • -r n,--reps=n 重复运行测试n次,r和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
  • -V, --version 打印版本号
  • -h, --help 打印帮助信息
  • -g, --get 拉取http头信息
  • -p, --print 打印整个页面的内容
  • -b, --benchmark 请求没有延迟
  • -H, --header="text" 给请求添加头,支持多个
  • -A, --user-agent="text" 给请求设置User-Agent
  • -T, --content-type="text" 给请求设置Content-Type

性能参数

参数

描述

Transactions

命中次数

Availability

命中率

Elapsed time

整个压测花费的时间,从第一个开始到最后一个结束

Data transferred

整个压测数据传输的总和

Response time

响应时间是响应每个模拟用户请求所花费的平均时间

Transaction rate

事务速率是服务器每秒能够处理的平均事务数. 简而言之:事务除以经过的时间

Throughput

吞吐量是从服务器到所有模拟用户每秒传输的平均字节数

Concurrency

并发是同时连接的平均数,这是一个随服务器性能下降而上升的数字

Successful transactions

成功事务次数

Failed transactions

失败事务次数

Longest transaction

最长事务时间

Shortest transaction

最短事务时间

显示默认配置

代码语言:javascript
复制
[root@docker35 ~]# siege -C
CURRENT  SIEGE  CONFIGURATION
Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.1
Edit the resource file to change the settings.
----------------------------------------------
version:                        4.1.1
verbose:                        true
color:                          true
quiet:                          false
debug:                          false
protocol:                       HTTP/1.1
HTML parser:                    enabled
get method:                     HEAD
connection:                     close
concurrent users:               25
time to run:                    n/a
repetitions:                    n/a
socket timeout:                 30
cache enabled:                  false
accept-encoding:                gzip, deflate
delay:                          0.000 sec
internet simulation:            false
benchmark mode:                 false
failures until abort:           1024
named URL:                      none
URLs file:                      /usr/local/etc/urls.txt
thread limit:                   500
logging:                        false
log file:                       /usr/local/var/log/siege.log
resource file:                  /root/.siege/siege.conf
timestamped output:             false
comma separated output:         false
allow redirects:                true
allow zero byte data:           true
allow chunked encoding:         true
upload unique files:            true
json output:                    false
no-follow:
 - ad.doubleclick.net
 - pagead2.googlesyndication.com
 - ads.pubsqrd.com
 - ib.adnxs.com
proxy auth:                     
www auth:                       

测试多个url

用法举例:

代码语言:javascript
复制
siege -c 200 -t 10S -i -d 1 -f url.txt

说明:-c是并发量,-t是时间。url.txt就是一个文本文件,每行都是一个url,它会从里面随机访问的。

url.txt文件内容如下:

代码语言:javascript
复制
https://www.xmmup.com/linuxchakanzuixiaohaoneicundejincheng.html
https://www.xmmup.com/changjiandelinuxcaozuoxitongneihecanshu.html
https://www.xmmup.com/
https://www.xmmup.com/neicunfenpeizhongdenuma.html
https://www.xmmup.com/linuxchakanzuixiaohaoneicundejincheng.html
https://www.xmmup.com/phpyouhuakuozhanopcache.html

结果说明:

  • Transactions: 30000 hits:完成30000次处理
  • Availability: 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:每次传输所花最短时间

压测单个网址

代码语言:javascript
复制
siege -c 1000 -t 10S https://www.xmmup.com

获取指定URL的Header信息,并显示HTTP处理信息

代码语言:javascript
复制
siege -g https://www.xmmup.com

其它测试

  • 在urls.txt中列出所有的网址
代码语言:javascript
复制
siege -c 200 -r 100 -f urls.txt
  • 随机选取urls.txt中列出所有的网址
代码语言:javascript
复制
siege -c 200 -r 100 -f urls.txt -i
  • delay=0,更准确的压力测试,而不是功能测试
代码语言:javascript
复制
siege -c 200 -r 100 -f urls.txt -i -b
  • 支持application/json方式请求
代码语言:javascript
复制
siege -c1 -r1 "http://192.168.16.101:6005/bpm/processInstances/review PUT <./1.json"
  • 支持多个Header参数
代码语言:javascript
复制
siege -c10 -r1 -p --header="Authorization: Bearer b7c75bae-9d68-4a74-bffb-95eb08a40918" --header="sg: 123456"
  • 指定http请求头文档类型
代码语言:javascript
复制
siege -H "Content-Type:application/json" -c 200 -r 100 -f urls.txt -i -b
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-08-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DB宝 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 简介
  • 安装
    • 性能参数
    • 显示默认配置
    • 测试多个url
    • 压测单个网址
    • 获取指定URL的Header信息,并显示HTTP处理信息
    • 其它测试
    相关产品与服务
    多因子身份认证
    多因子身份认证(Multi-factor Authentication Service,MFAS)的目的是建立一个多层次的防御体系,通过结合两种或三种认证因子(基于记忆的/基于持有物的/基于生物特征的认证因子)验证访问者的身份,使系统或资源更加安全。攻击者即使破解单一因子(如口令、人脸),应用的安全依然可以得到保障。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档