IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发测试 -> Linux之压测工具Siege安装和使用 -> 正文阅读

[开发测试]Linux之压测工具Siege安装和使用

一、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
在这里插入图片描述

  开发测试 最新文章
pytest系列——allure之生成测试报告(Wind
某大厂软件测试岗一面笔试题+二面问答题面试
iperf 学习笔记
关于Python中使用selenium八大定位方法
【软件测试】为什么提升不了?8年测试总结再
软件测试复习
PHP笔记-Smarty模板引擎的使用
C++Test使用入门
【Java】单元测试
Net core 3.x 获取客户端地址
上一篇文章      下一篇文章      查看所有文章
加:2021-09-10 11:09:24  更:2021-09-10 11:09:40 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/20 23:26:49-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码