Siege – HTTPS 网站压力测试超棒的工具
身为站长,偶尔想帮网站做一下压力测试也是正常,通过压力测试我们可以了解伺服器架构的稳定,以及在某种层面上观察程式的效能,常见的工具有ab 、jMeter 等等,今天yama要跟大家介绍Siege,它是个功能完善但又简单的HTTPS 压力测试工具,用命令列的方式执行,透过Siege 可以帮助你测试网站、API 的负载能力,但也要注意效能测试是很多层面的事情,并非压力测试通过就万无一失哦!测试完一波,yama的ip地址成功被封ovo,~
文件下载地址:Github: https://github.com/JoeDog/siege
windows安装比较麻烦,要装 cygwin,很蛋疼~,mac和linux还是比较方便的,这里yama以mac为例。直接用Homebrew 安装更为方便,并不需要下载siege(当然也行只不过太麻烦~)
Homebrew 是基于 OS X 的套件管理工具,是一个开源的 Ruby 脚本,专门用于快速下载软件。更通俗地说,Homebrew 类似于一个软件中心,你可以理解成 App Store 或者 Google Play 那样的软件商店,只不过,Homebrew 比前者以及 Mac App Store 来说有着更丰富的资源与更高效的管理。
Homebrew优势
有什么优势 通过 Homebrew 下载安装的软件全部来自对应的软件官网,无需担心下载源的安全问题。
依存于系统既有的库,减少了空间占用和冗余 使用 Git 进行管理和更新 易于定制 安装软件 / 软件包 / 软件都在一个目录下,方便管理,这也是 Homebrew 能如此受欢迎的最大原因之一。
Homebrew Cask 的常用命令非常简单,也很好理解,虽然是通过命令行,但你完全不需要对「终端」「命令行」有过多了解,也能很快上手。
如果显示没有安装homebrew,只需要一条命令/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
,就ojbk了。
在Mac上安装siege
brew install sige
参数
siege –help
SIEGE 3.0.6
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.
#在屏幕上打印显示出当前的配置,配置是包括在他的配置文件$HOME/.siegerc中,
#可以编辑里面的参数,这样每次siege 都会按照它运行.
-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.
-c, –concurrent=NUM CONCURRENT users, default is 10
#模拟有n个用户在同时访问,n不要设得太大,因为越大,siege 消耗本地机器的资源越多
–i, –internet INTERNET user simulation, hits URLs randomly.
#随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性)
-b, –benchmark BENCHMARK: no delays between requests.
-t, –time=NUMm TIMED testing where “m” is modifier S, M, or H
ex: –time=1H, one hour test.
#持续运行siege ‘n’秒(如10S),分钟(10M),小时(10H)
-r, –reps=NUM REPS, number of times to run the test.
#重复运行测试n次,不能与 -t同时存在
-f, –file=FILE FILE, select a specific URLS FILE.
#指定用urls文件,默认为siege安装目录下的etc/urls.txt
#urls.txt文件:是很多行待测试URL的列表以换行符断开,格式为:
#[protocol://] http://host.domain.com[:port][path/to/file]
-R, –rc=FILE RC, specify an siegerc file
#指定用特定的siege配置文件来运行,默认的为$HOME/.siegerc
-l, –log[=FILE] LOG to FILE. If FILE is not specified, the
default is used: PREFIX/var/siege.log
#运行结束,将统计数据保存到日志文件siege.log中,可在.siegerc中自定义日志文件
-m, –mark=“text” MARK, mark the log file with a string.
-d, –delay=NUM Time DELAY, random delay before each requst
between 1 and NUM. (NOT COUNTED IN STATS)
#hit每个url之间的延迟,在0-n之间
-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
Copyright (C) 2014 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.
结果说明** SIEGE 2.72
** Preparing 300 concurrent
users
for
battle.
The server is now under siege..
done.
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
#每次传输所花最短时间
这里先测试下自己的小网站- https://share.earnrmb.us,用命令siege -d 10-c 20 -r 10 https://share.earnrmb.us
,表示同时20个人,持续 10次hits网站,(-c并发,-r重复次数()
然后…网站倒是没问题,成功把自家的ip给封了~~
不要搞我网站哈~,憋把自己ip搞封了2333~