欢迎访问 夜阑小雨 我的学习碎片档案,这里记录了我的学习内容和工作中经验,希望给您带去帮助。

Siege-Web压力测试工具

Linux学习 夜阑小雨 1016℃ 0评论

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

官方网址:http://www.joedog.org/

下载网址:ftp://ftp.joedog.org/pub/,进入到ftp://ftp.joedog.org/pub/siege/下载最新版:

siege-2.70.tar.gz。

安装解压:tar zxvf siege-2.70.tar.gz,进入到解压后的目录:siege-2.70,运行命令:

./configure

make

make install

安装完毕后如果有错误,则按照提示信息处理即可

输入:siege –help,如果安装没问题会出现以下类似信息:

SIEGE 2.70

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.

-v, –verbose           VERBOSE, prints notification to screen.

-g, –get               GET, pull down HTTP headers and display the

transaction. 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 H

ex: –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, the

default 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 requst

between 1 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

Copyright (C) 2010 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.

上面也是运行的一些参数,右边是对一些参数的解释说明

比如:

–C :查看siege当前的配置信息

–V:版权说明信息

–c:并行启动(访问)用户数,默认是10

-t:压力测试时间,比如-t5表示持续时间是5分钟

-r:每个连接发出的请求数量,这个与t有些类似,所以设置了这个值就不需要设置t了,反之亦然。

-f:对应一个文件,这个文件里每一行为一个URL链接,格式如:

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/2010/12/14/2806/

好了,主要的一些参数说明就介绍这么多,其余的可以参考上面的英文。

使用:

1、  启动100个用户(线程)在5分钟内对某一页面www.zihou.me进行并发访问

siege http://www.zihou.me -c200 -t5

2、  对多个页面进行并发访问

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

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/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

如果在并发的过程中,被访问的页面打开出错或及其缓慢,表示在当前并发条件下,被访问网站是不能承受的,也就是抗并发能力弱。

另外,在并发的过程中最好通过top命令来查看CPU和Memory的占用情况。

转载请注明:夜阑小雨 » Siege-Web压力测试工具

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址