当前位置:首页 » 《资源分享》 » 正文

Linux之压测工具Siege安装和使用_月生的静心苑

29 人参与  2021年09月23日 17:03  分类 : 《资源分享》  评论

点击全文阅读


文章目录

  • 一、Siege简介
  • 二、安装步骤
    • 0、登录官网检查确认最新版本
    • 1、下载软件包
    • 2、解压软件包
    • 3、编译安装
    • 4、查看命令
    • 5、获取命令帮助
  • 三、使用说明
    • 1、使用语法
    • 2、参数说明
    • 3、使用示例
      • 1)、查看siege配置
      • 2)、查看工具版本
      • 3)、获取指定URL的Header信息
      • 4)、并发1000测试1000
      • 5)、并发100用户测试指定文件中的url
      • 6)、并发100测试60秒
  • 四、测试结果说明
  • 五、QA
    • 1、配置1000并发用户测试是报错

一、Siege简介

  Siege是一个http/ftp负载测试工具和基准测试工具。它是为开发人员和管理员设计的,用于测量其应用程序在负载下的性能。它可以向服务器发送可配置数量的并发请求。Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载。

二、安装步骤

0、登录官网检查确认最新版本

登录官网siege官网查看siege软件最新版本,当前最新版本为4.1.1(截止至2021年9月1日)
在这里插入图片描述

1、下载软件包

点击上一步中版本链接下载。
或者直接在Linux服务器上下载。
[root@test1 opt]# wget http://download.joedog.org/siege/siege-4.1.1.tar.gz

2、解压软件包

[root@test1 local]# tar -zxvf siege-4.1.1.tar.gz

3、编译安装

[root@test1 local]# cd siege-4.1.1/
[root@test1 siege-4.1.1]# ./configure

--------------------------------------------------------
Configuration is complete

Run the following commands to complete the installation:
make
make install

For complete documentation: http://www.joedog.org
--------------------------------------------------------
[root@test1 siege-4.1.1]# make && make install

make[2]: Leaving directory `/usr/local/siege-4.1.1/html’
make[1]: Leaving directory `/usr/local/siege-4.1.1/html’

4、查看命令

[root@test1 siege-4.1.1]# which siege
/usr/local/bin/siege

5、获取命令帮助

[root@test1 siege-4.1.1]# siege --help
在这里插入图片描述

三、使用说明

1、使用语法

siege [参数] url
url文件就是一个文本,文本中每行是一个url。

2、参数说明

参数参数说明
-V, --version版本,打印版本号。
-h, --help帮助,打印此部分。
-C, --config配置,显示当前配置。
-v, --verbose详细,将通知打印到屏幕。
-q, --quiet安静关闭冗余并抑制输出。
-g, --get获取、下拉HTTP头并显示,适合应用程序调试
-p, --print打印,就像只获取一样,它打印整个页面。
-c, --concurrent=NUM并发用户,默认值为10
-r, --reps=NUM重复次数,运行测试的次数。
-t, --time=NUMm定时测试,其中“m”是修饰符S、m或H ; ex:–时间=1H,一小时试验。
-d, --delay=NUM时间延迟,每个请求前的随机延迟
-b, --benchmark基准测试:请求之间没有延迟。
-i, --internet互联网用户模拟,随机点击网址。
-f, --file=FILE文件,选择特定的URL文件。
-R, --rc=FILERC,指定一个siegerc文件
-l, --log[=FILE]记录到文件。如果未指定文件,则使用默认值:前缀/var/seake.log
-m, --mark=“text”标记,用字符串标记日志文件, 介于.001和NUM之间(不计入统计数据)
-H, --header=“text”向请求添加标头(可以是多个)
-A, --user-agent=“text”在请求中设置用户代理
-T, --content-type=“text”设置请求中的内容类型
-j, --json-outputJSON输出,将最终统计数据作为JSON打印到标准输出
–no-parser没有解析器,请关闭HTML页面解析器
–no-follow不跟随,不跟随HTTP重定向

3、使用示例

1)、查看siege配置

[root@test1 ~]# siege --config
[alert] Zip encoding disabled; siege requires zlib support to enable it
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: *
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: 255
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:

2)、查看工具版本

[root@test1 ~]# siege --version
[alert] Zip encoding disabled; siege requires zlib support to enable it
SIEGE 4.1.1

Copyright © 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.

3)、获取指定URL的Header信息

[root@test1 ~]# siege -g http://www.baidu.com
[alert] Zip encoding disabled; siege requires zlib support to enable it
HEAD / HTTP/1.0
Host: www.baidu.com
Accept: /
Accept-Encoding: *
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.1
Connection: close

HTTP/1.0 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Thu, 09 Sep 2021 07:12:50 GMT
Etag: “575e1f6f-115”
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Pragma: no-cache
Server: bfe/1.0.8.18

Transactions: 1 hits
Availability: 100.00 %
Elapsed time: 0.04 secs
Data transferred: 0.00 MB
Response time: 0.04 secs
Transaction rate: 25.00 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 1.00
Successful transactions: 1
Failed transactions: 0
Longest transaction: 0.04
Shortest transaction: 0.04

4)、并发1000测试1000

[root@test1 ~]# siege -c1000 -r10000 http://192.168.0.213:8098/dist/#/index?id=a3178a9b829e7dfef4668fddc68fc5ab
在这里插入图片描述

5)、并发100用户测试指定文件中的url

[root@test1 tmp]# cat testurl.txt
http://192.168.0.213:8098/dist/#/index?id=a3178a9b829e7dfef4668fddc68fc5ab
http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
http://192.168.0.213:8098/dist/#/index?id=40f123f28dfd968652f6a61556c986b2
[root@test1 tmp]# siege -c100 -r1000 -f testurl.txt
在这里插入图片描述

6)、并发100测试60秒

[root@test1 tmp]# siege -c100 -t 60S http://192.168.0.213:8098/dist/#/index?id=40f123f28dfd968652f6a61556c986b2

Lifting the server siege…
Transactions: 29264 hits
Availability: 100.00 %
Elapsed time: 59.70 secs
Data transferred: 295.88 MB
Response time: 0.17 secs
Transaction rate: 490.18 trans/sec
Throughput: 4.96 MB/sec
Concurrency: 85.12
Successful transactions: 29264
Failed transactions: 0
Longest transaction: 12.06
Shortest transaction: 0.00

四、测试结果说明

Transactions: 34925 hits (处理次数,本次处理了34925此请求)
Availability: 100.00 % (可用性/成功次数的百分比,比如本次100%成功)
Elapsed time: 34.83 secs (运行时间,本次总消耗34.83秒)
Data transferred: 353.18 MB (数据传送量)
Response time: 0.83 secs(响应时间)
Transaction rate: 1002.73 trans/sec (处理请求频率,每秒钟处理8.89次请求)
Throughput: 10.14 MB/sec (吞吐量,传输速度)
Concurrency: 833.76 (实际最高并发连接数)
Successful transactions: 34931(成功的传输次数)
Failed transactions: 0 (失败的传输次数)
Longest transaction: 30.86 (处理传输是所花的最长时间)
Shortest transaction: 0.01(处理传输是所花的最短时间)

五、QA

1、配置1000并发用户测试是报错

  • 报错信息
    在这里插入图片描述
  • 解决方案

[root@test1 ~]# vim /root/.siege/siege.conf
在这里插入图片描述


点击全文阅读


本文链接:http://zhangshiyu.com/post/28433.html

并发  请求  测试  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1