介绍
Siege是一个http/https负载测试和基准测试工具。它旨在让WEB开发人员了解自己代码在压力测试中的执行性能。
Siege支持基本身份验证、Coockie、HTTP、HTTPS和FTP协议。用户也可以通过配置来模拟访问服务器的并发用户数,是一款非常方便的压力测试工具。
官方网址:http://www.joedog.org
下载网址:http://www.joedog.org/pub/siege
安装配置
安装版本:Siege-4.0.2
操作系统:Centos7.x
安装
shell> yum install siege -y
使用介绍
shell> siege -V
SIEGE 4.0.2
shell> siege --help
-C, --config :查看siege当前的配置信息
-V, --version:版权说明信息
-c, --concurrent=NUM:并行启动(访问)用户数,默认是10
-t, --time=NUMm:压力测试时间,比如-t5表示持续时间是5分钟
-b, --benchmark:基准测试,请求之间没有延迟。
-g, --get get方式请求
-d, --delay=NUM 时间延迟,每个请求之间的延迟时间
-i, --internet 模拟用户,随机点击的URL。
-r, --reps=NUM:每个连接发出的请求数量,这个与t有些类似,所以设置了这个值就不需要设置t了,反之亦然。
-f, --file=FILE:对应一个文件,这个文件里每一行为一个URL链接,格式如:
-m, --mark="text" 在日志里标记的字符串标识
-H, --header="text" 在Header里增加的字符串标识
-A, --user-agent="text" 在user-agent里增加的字符串标识
-u, --url="URL" 设置被测Web的URL
实战说明
# 10个并发,每个连接10个请求,间隔1秒请求压测。
shell> siege -u www.baidu.com -d1 -r10 -c 10
# 结果:
HTTP/1.1 200 0.05 secs: 143913 bytes ==> GET /static/superman/js/lib/jquery-1-cc52697ab1.10.2.js
HTTP/1.1 200 0.04 secs: 15629 bytes ==> GET /5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css
HTTP/1.1 200 0.05 secs: 163321 bytes ==> GET /
HTTP/1.1 200 0.02 secs: 93750 bytes ==> GET /r/www/cache/static/jquery/jquery-1.10.2.min_65682a2.js
HTTP/1.1 200 0.05 secs: 6511 bytes ==> GET /img/[email protected]
HTTP/1.1 200 0.02 secs: 1131 bytes ==> GET /baidu.html?from=noscript
HTTP/1.1 200 0.01 secs: 705 bytes ==> GET /img/baidu_jgylogo3.gif
HTTP/1.1 200 0.04 secs: 6511 bytes ==> GET /img/[email protected]
HTTP/1.1 200 0.01 secs: 705 bytes ==> GET /img/baidu_jgylogo3.gif
HTTP/1.1 200 0.04 secs: 7877 bytes ==> GET /img/bd_logo1.png?qua=high
HTTP/1.1 200 0.01 secs: 7877 bytes ==> GET /img/bd_logo1.png?qua=high
HTTP/1.1 200 0.02 secs: 7877 bytes ==> GET /img/bd_logo1.png
HTTP/1.1 200 0.04 secs: 7877 bytes ==> GET /img/bd_logo1.png
HTTP/1.1 200 0.10 secs: 91 bytes ==> GET /img/gs.gif
HTTP/1.1 200 0.03 secs: 15629 bytes ==> GET /5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css
HTTP/1.1 200 0.06 secs: 93750 bytes ==> GET /r/www/cache/static/jquery/jquery-1.10.2.min_65682a2.js
HTTP/1.1 200 0.01 secs: 6511 bytes ==> GET /img/[email protected]
HTTP/1.1 200 0.01 secs: 705 bytes ==> GET /img/baidu_jgylogo3.gif
HTTP/1.1 200 0.05 secs: 7877 bytes ==> GET /img/bd_logo1.png?qua=high
HTTP/1.1 200 0.01 secs: 7877 bytes ==> GET /img/bd_logo1.png
HTTP/1.1 200 0.02 secs: 163294 bytes ==> GET /
HTTP/1.1 200 0.04 secs: 1131 bytes ==> GET /baidu.html?from=noscript
HTTP/1.1 200 0.01 secs: 91 bytes ==> GET /img/gs.gif
HTTP/1.1 200 0.03 secs: 15629 bytes ==> GET /5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css
HTTP/1.1 200 0.06 secs: 93750 bytes ==> GET /r/www/cache/static/jquery/jquery-1.10.2.min_65682a2.js
HTTP/1.1 200 0.02 secs: 6511 bytes ==> GET /img/[email protected]
HTTP/1.1 200 0.01 secs: 705 bytes ==> GET /img/baidu_jgylogo3.gif
HTTP/1.1 200 0.05 secs: 7877 bytes ==> GET /img/bd_logo1.png?qua=high
HTTP/1.1 200 0.00 secs: 7877 bytes ==> GET /img/bd_logo1.png
Transactions: 1017 hits // 总处理数量
Availability: 100.00 % // 成功请求百分百
Elapsed time: 10.06 secs //总耗时
Data transferred: 35.65 MB //总传输数据量
Response time: 0.03 secs // 响应时间
Transaction rate: 101.09 trans/sec // 每秒处理请求数
Throughput: 3.54 MB/sec // 吞吐量
Concurrency: 3.38 // 并发数
Successful transactions: 1017 //成功处理次数
Failed transactions: 0 //请求失败数
Longest transaction: 0.33 // 请求最长耗时
Shortest transaction: 0.00 //请求最短耗时
GET方式压测
shll> siege -g www.baidu.com
HEAD / HTTP/1.0
Host: www.baidu.com
Accept: */*
User-Agent: Mozilla/5.0 (redhat-x86_64-linux-gnu) Siege/4.0.2
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: Sun, 01 Mar 2020 13:25:22 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Transactions: 1 hits
Availability: 100.00 %
Elapsed time: 0.52 secs
Data transferred: 0.00 MB
Response time: 0.05 secs
Transaction rate: 1.92 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 0.10
Successful transactions: 1
Failed transactions: 0
Longest transaction: 0.05
Shortest transaction: 0.05
更多文章和资料 ↓↓↓
阿里云K8s实战手册 K8s
阿里云CDN排坑指南 CDN
ECS运维指南 ECS
DevOps实践手册 DevOps
Hadoop大数据实战手册 Hadoop