siege简介

Siege是一款不错的网站压力测试工具,它可以非常容易地定制并发访问人数以及并发时间.
其安装、使用也非常方便,当然它是在Linux类环境下使用的,下面来对它作一个介绍。

安装

在mac上,可以使用brew来直接安装。
$ brew install siege

$ siege –help

SIEGE 3.1.3
Usage: siege [options]siege [options] URLsiege -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 thetransaction. Great for application debugging.-c, --concurrent=NUM      CONCURRENT users, default is 10-i, --internet            INTERNET user simulation, hits URLs randomly.-b, --benchmark           BENCHMARK: no delays between requests.-t, --time=NUMm           TIMED testing where "m" is modifier S, M, or Hex: --time=1H, one hour test.-r, --reps=NUM            REPS, number of times to run the test.-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, thedefault is used: PREFIX/var/siege.log-m, --mark="text"         MARK, mark the log file with a string.-d, --delay=NUM           Time DELAY, random delay before each requstbetween .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 requestCopyright (C) 2015 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.

要使用最新的版本,去官网下载最新的源码进行build。
官方网址:http://www.joedog.org/

下载最新的版本源码,目前最新版本4.0.2,解压后,进入目录,执行:

$ ./configure
$ make
$ make install

完成后,siege执行文件被拷贝到/usr/local/bin/下。
执行一下
$ siege --help

[alert] Zip encoding disabled; siege requires zlib support to enable it
SIEGE 4.0.2
Usage: siege [options]siege [options] URLsiege -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 thetransaction. Great for application debugging.-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 Hex: --time=1H, one hour test.-d, --delay=NUM           Time DELAY, random delay before each requst-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, thedefault 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 requestCopyright (C) 2016 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.

使用1

比如,狗厂的兄弟对某个url进行简单的http访问压测:

$ siege -c100 -t60s -b http://***.item.com/999888  

并发测试完毕后,打印出结果信息:

Transactions: 337998 hits
Availability: 100.00 %
Elapsed time: 59.09 secs
Data transferred: 2021.07 MB
Response time: 0.03 secs
Transaction rate: 5720.05 trans/sec
Throughput: 34.20 MB/sec
Concurrency: 149.79
Successful transactions: 337998
Failed transactions: 0
Longest transaction: 1.07
Shortest transaction: 0.00

$ siege -c600 -t60s -b http://***.item.jd.com/981821 

并发测试完毕后,打印出结果信息:

Transactions: 370985 hits
Availability: 100.00 %
Elapsed time: 59.16 secs
Data transferred: 2218.32 MB
Response time: 0.10 secs
Transaction rate: 6270.88 trans/sec
Throughput: 37.50 MB/sec
Concurrency: 598.31
Successful transactions: 370985
Failed transactions: 0
Longest transaction: 1.32
Shortest transaction: 0.00

如果在并发的过程中,被访问的页面打开出错或及其缓慢,表示在当前并发条件下,被访问网站是不能承受的,也就是抗并发能力弱。
另外,在并发的过程中最好通过top命令来查看CPU和Memory的占用情况。

使用2: 对多个页面进行并发访问

新建一个文件,命名为urls,里面的内容为(只是例子,任何url都可以):

http://www.taobao.com
http://www.taobao.com/2010/12/16/2821/
http://www.taobao.com/2010/12/14/2806/

执行命令:

$ siege -f urls -c200 -t5

表示启动200个用户在5分钟内并发访问以上的url网址。

并发测试完毕后,打印出结果信息:

Lifting the server siege… done.
Transactions: 7555 hits
Availability: 99.47 %
Elapsed time: 299.92 secs
Data transferred: 99.17 MB
Response time: 7.30 secs
Transaction rate: 25.19 trans/sec
Throughput: 0.33 MB/sec
Concurrency: 183.84
Successful transactions: 7555
Failed transactions: 40
Longest transaction: 17.94
Shortest transaction: 0.02

使用siege 3.#版本进行http post

在使用http post方式时,结合http body类型。
siege -T ‘application/json’ -c 500 -r 1 ‘http://some.url./post-service/ POST <./postfile’
服务器端接收到body为postfile文件内容,但是content_type依旧是默认值“application/x-www-form-urlencoded”,致使服务器端不能正确处理。

将postfile文件名修改为postfile.json
siege -c 500 -r 1 ‘http://some.url./post-service/ POST <./postfile.json’
content_type被正确设置为application/json,服务器正常处理返回。
原来siege只能通过文件的扩展名来确定content type格式

对比apache的ab命令

该工具比较好用,没出现什么问题,一条命令搞定:
ab -n 5000 -c 500 -p postfile -T ‘application/json’ ‘http://some.url./post-service/’

ab 命令help

Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:-n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000-s timeout      Seconds to max. wait for each response
                    Default is 30 seconds-b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    'application/x-www-form-urlencoded'Default is 'text/plain'-v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234'. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)-A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.-P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.-X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -l              Accept variable document length (use this for dynamic pages)
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -m method       Method name
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

web压力测试之siege相关推荐

  1. Siege(开源Web压力测试工具)——多线程编程最佳实例

    在英语中,"Siege"意为围攻.包围.同时Siege也是一款使用纯C语言编写的开源WEB压测工具,适合在GNU/Linux上运行,并且具有较强的可移植性.之所以说它是多线程编程的 ...

  2. CentOS上安装Web性能测试工具Siege 示例

    2019独角兽企业重金招聘Python工程师标准>>> 本文记录一次在CentOS上安装Web性能测试工具Siege的步骤,并对安装过程中遇到的问题进行解决~ Siege是什么? S ...

  3. python的web压力测试工具-pylot安装使用

    pylot是python编写的一款web压力测试工具.使用比较简单.而且测试结果相对稳定. 这里不得不鄙视一下apache 的ab测试,那结果真是让人蛋疼,同样的url,测试结果飘忽不定,看得人心惊肉 ...

  4. asp.net core系列 67 Web压力测试工具WCAT

    asp.net core系列 67 Web压力测试工具WCAT 原文:asp.net core系列 67 Web压力测试工具WCAT 一.介绍 最近搭建了一套CQRS框架,需要在投入开发前,进行必要的 ...

  5. jmetter持续时间_【转】Jmeter做web压力测试时设置持续时间注意点

    头一回使用jmeter做web的压力测试,遇到个很莫名其妙的问题,不管我的线程组怎么设置,它就是执行一次就结束了. 设置循环次数为300,不使用调度器--〉执行一次就结束了,循环次数未生效 设置循环次 ...

  6. [MySQL]-压力测试之TPCC-MySQL

    [MySQL]-压力测试之TPCC-MySQL 文章目录 [MySQL]-压力测试之TPCC-MySQL 一.基本概念 1.1 基准测试VS压力测试 1.2 TPCC是什么? 1.3 TPCC-MyS ...

  7. [MySQL]-压力测试之Sysbench

    [MySQL]-压力测试之Sysbench 文章目录 [MySQL]-压力测试之Sysbench 一.Sysbench概况 1)介绍 2)安装部署 二.实战 1)构造测试数据 2)开始运行 压测结果解 ...

  8. web渗透测试之攻破登录页面

    web渗透测试之攻破登录页面 当我们在做渗透测试时,无论厂商项目还是src众测项目,都会遇到给一堆登录系统的URL,然后让我们自己去测,能不能进去全看天的状况,本文将讲一下怎么突破这种封闭的web系统 ...

  9. web安全测试之appscan – “X-Content-Type-Options”头缺失或不安全

    web安全测试之appscan - "X-Content-Type-Options"头缺失或不安全 - 猿码设计师web 安全测试 appscan; 通过设置"X-Con ...

最新文章

  1. c语言x在二进制表示下1的个数,算法:计算十进制数字在二进制表示1的个数,...
  2. GCC编译选项--创建与使用库
  3. Oracle DBA学习互联网化的内容
  4. tinyxml 内存泄露_有关TinyXML使用的简单总结
  5. css 动态rem_【面试题】CSS知识点整理(附答案)
  6. STM32用keil5调试程序出现 Error:Flash Download Failed-Cortex-M3解决方案
  7. DVB-C系统中QAM调制与解调仿真
  8. linux源码文件名,Linux中文件名解析处理源码分析
  9. php sql desc,PHP SQL 查询封装
  10. 华为就5G网络设备禁令起诉瑞典邮政和电信管理局
  11. centos系统中卸载软件【例子为卸载百度硬盘】
  12. 正态分布的前世今生(下)
  13. J2EE 各种关系逻辑图
  14. ReentrantReadWriteLock源码解读
  15. matlab中的方波信号图片_哈工大、哈工程MATLAB被禁用,这个国产软件号称可替代!...
  16. java试题管理系统
  17. DVP和MIPI接口的简单区别
  18. 各种关于函数的定义01(高数)
  19. C++ 函数模板 实例化和具体化
  20. vvic、小红书API接口调用

热门文章

  1. BZOJ3527:[ZJOI2014]力(FFT)
  2. html部分位置属性
  3. 《道德经》程序员版第五章
  4. python输入input数组_Python学习——实现简单的交互raw_input的使用
  5. 图片不能及时显示_湘D车主注意!衡阳多个十字路增设电子显示屏
  6. Ant找不到rt.jar
  7. struts2从一个action跳到另一个action的配置方法
  8. javscript 实现iframe加载内容页出现LOADING效果
  9. time函数python_Python连载6-time包函数简介
  10. 通用技术和信息技术合格考知识点_高二信息与通用技术会考知识点