Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1610714
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类: LINUX

2011-11-03 09:36:49

官方网站

 

//siege -c 100 -t 10s -l /usr/local/var/siege.log

 

Siege是一个多线程http负载测试和基准测试工具。它3种操作模式:

1)        Regression (when invoked by bombardment)Siege从配置文件中读取URLs,按递归方式,逐个发送请求

2)        Internet simulation (Siege从配置文件中读取URLs,随机选取URL发送请求)

3)        Brute force (在命令行上写上一个单独的URL,发送请求)

 

安装:

1。wget

2。./configure

3。make

4。make install

siege用法:

[root@testcms ~]# 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.

--------------

URL格式

 

支持的格式:

[protocol://] host.domain.xxx [:port] [/path/file]

host.domain.xxx/file POST field=value&field2=value2

host/file POST

在命令行上输入URL时,最好用引号括起来。目前支持httphttps两种协议。没有写明协议,默认http

当一次测试中需要多个URL时,可以将URLs放到一个单独的文件中。默认$SIEGE_HOME/etc/urls.txt

例如:urls.txt

# 这里表述注释,一行一个URL

POST scope=a

POST a=1&b=2

# POST文件

POST

POST <./my.txt

 

Siege一次性将文件读入内存,按照文件中顺序发送请求。[-i]选项可以随机发送URL请求。

 

在文件中,我们可以设置和引用变量。先定义后引用原则。一个变量一行,类似于shell变量,引用时用$()或者${},如

 HOST = homer.whoohoo.com

 {HOST}/index.html

如果变量不存在,则表示空字符串。

-------------------

测试报告

测试结果会打印在屏幕上,格式如下

** Siege 2.70

** Preparing 100 concurrent users for battle.

       The server is now under siege...done

       Transactions:                    339 hits

       Availability:                  93.39 %

       Elapsed time:                  67.47 secs

       Data transferred:            4273708 bytes

       Response time:                  8.25 secs

       Transaction rate:               5.02 trans/sec

       Throughput:                 63342.34 bytes/sec

       Concurrency:                   41.47

       Successful transactions:         337

       Failed transactions:              26

       Longest transaction:           17.77 secs

       Shortest transaction:           0.37 secs

 

各项含义说明

Transactions

The number of server hits.一般等于num1 * num2  (-c num1 -r num2) 。有时会超过这个值例如重定向会算做2hit

Availability

服务器成功处理的socket连接的百分比。这个数字不包含400500级别的错误。

Elapsed time

本次测试所消耗的时间。

Data transferred

传输数据的总和。它包含headercontent,所以数字可能会大于服务端的数字。如果使用[-i]选项,因为每次请求的URL是从urls.txt中随机选取的,所以这个值每次运行都会不同。

Response time

平均响应时间。

Transaction rate

这个就是TPS

Throughput

server到模拟用户的每秒传输数据量[bytes],即吞吐率。

Concurrency

同时连接数平均值。该值的上升伴随着服务器性能的下降。

Successful transactions

服务器响应code<400的请求次数。

Failed transactions

服务器响应code>=400,加上处理失败的socket连接(包含timeout)的数量。

------------------------------

有时我们会遇到-c500以上出现timeout(排除server端原因),这可能是siege引起的,单个进程所启动的线程数限制。可以使用shell调用方式,多进程运行。

------------------------

系统优化设置

sysctl -w net.ipv4.tcp_tw_reuse=1表示开启重用允许将TIME-WAIT Sockets重新用于新的TCP连接默认为0表示关闭。

sysctl -w net.ipv4.tcp_tw_recycle=1表示开启TCP连接中TIME-WAIT Sockets的快速回收默认为0表示关闭。

sysctl -w net.ipv4.tcp_fin_timeout=30参数tcp_fin_timeout 是套接字关闭时保持FIN-WAIT-2状态的时间。

ulimit -n查看单个进程可以open files的数量。修改方式

1. 按照最大打开文件数量的需求设置系统 并且通过检查/proc/sys/fs/file-max文件来确认最大打开文件数已经被正确设置。

     # cat /proc/sys/fs/file-max

如果设置值太小, 修改文件/etc/sysctl.conf的变量到合适的值。 这样会在每次重启之后生效。 如果设置值够大,跳过下步。

     # echo 20000 > /proc/sys/fs/file-max

编辑文件/etc/sysctl.conf插入下行。     fs.file-max = 20000

2. /etc/security/limits.conf文件中设置最大打开文件数 下面是一行提示

     #                

添加如下这行。      * - nofile 20000

这行设置了每个用户的默认打开文件数为20000 注意"nofile"项有两个可能的限制措施。

-----------

注:本文部分内容摘抄于网上。

---------------------------------------------------------------------------------------------


阅读(1411) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~