1. Introduce to Siege.
Siege is a multi-threaded http load testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress. It allows one to hit a web server with a configurable number of concurrent simulated users. Those users place the web server "under siege." Performance measures include elapsed time, total data transferred, server response time, its transaction rate, its throughput, its concurrency and the number of times it returned OK. These measures are quantified and reported at the end of each run. Their meaning and significance is discussed below. Siege has essentially three modes of operation: regression (when invoked by bombardment), internet simulation and brute force.
2. How to Install Siege
2.1 Where is Siege available?
Siege utility can be downloaded in URL http://www.joedog.org/JoeDog/Siege,
or can be use the command
wget ftp://ftp.joedog.org/pub/siege/siege-latest.tar.gz
2.2 Decompress the file siege-beta.tar.
[root@localhost ~]# tar -xvf siege-beta.tar
2.3 compile
[root@localhost ~]# cd siege-2.67b3/
[root@localhost ~]# ./configure
[root@localhost ~]# make
2.4 install on any linux
[root@localhost ~]# su
[root@localhost ~]# cd /home/admin/siege-2.67b3/
[root@localhost ~]# make install
2.5 You can install on ubuntu ,used the command “ sudo apt-get install siege”
Following Above instructions, siege can be run as you want. Let’s have a look with it.
bdong@bdong-desktop:~$ siege -c 1 -r 3 www.baidu.com
** SIEGE 2.66
** Preparing 1 concurrent users for battle.
The server is now under siege...
HTTP/1.0 200 0.88 secs: 1745 bytes ==> /
HTTP/1.0 200 0.32 secs: 1745 bytes ==> /
HTTP/1.0 200 0.31 secs: 1745 bytes ==> /
done.
Transactions: 3 hits
Availability: 100.00 %
Elapsed time: 4.53 secs
Data transferred: 0.00 MB
Response time: 0.50 secs
Transaction rate: 0.66 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 0.33
Successful transactions: 3
Failed transactions: 0
Longest transaction: 0.88
Shortest transaction: 0.31
FILE: /var/siege.log
You can disable this annoying message by editing
the .siegerc file in your home directory; change
the directive 'show-logfile' to false.
Error: unable to create log file: Permission denied
3. Usage introduce to Siege.
Siege is a test utility to simulate mutil-user concurrently access at a period of time for measure the Server performance including elapsed time, total data transferred, server response time, its transaction rate, its throughput, its concurrency and the number of times it returned OK. To be simplify, there are two parts must to be explained.
3.1 How to generate traffic (or pressure) to Server.
bdong@bdong-desktop:~$ siege --help
SIEGE 2.66
Usage: siege [options]
siege [options] URL
siege -g URL
Options:
-C, --config CONFIGURATION, show the current configuration.
-V, --version VERSION, prints version number to screen.
-h, --help HELP, prints this section.
-c, --concurrent=NUM CONCURRENT users, default is 10
-i, --internet INTERNET user simulation, hits the URLs randomly.
-r, --reps=NUM REPS, number of times to run the test, default is 25
-l, --log LOG, logs the transaction to PREFIX/var/siege.log
-R, --rc=FILE RC, change the siegerc file to file. Overrides
the SIEGERC environmental variable.
-f, --file=FILE FILE, change the configuration file to file.
3.2 To be configured the .siegerc
bdong@bdong-desktop:/etc/siege$ pwd
/etc/siege
bdong@bdong-desktop:/etc/siege$ ls
siege.2009-08-04T09:56+0800 siegerc urls.txt
bdong@bdong-desktop:/etc/siege$
bdong@bdong-desktop:/etc/siege$ cat siegerc
# Updated by Siege 2.66, June-20-2008
# Copyright 2005 by Jeffrey Fulmer, et al.
#
# Siege configuration file -- edit as necessary
# For more information about configuring and running
# this program, visit: http://www.joedog.org/
#
# Show logfile location. By default, siege displays the
# logfile location at the end of every run when logging
# You can turn this message off with this directive.
# ex: show-logfile = false
#
show-logfile = false
#
# Internet simulation. If true, siege clients will hit
# the URLs in the urls.txt file randomly, thereby simulating
# internet usage. If false, siege will run through the
# urls.txt file in order from first to last and back again.
# ex: internet = true
#
internet = false
#
# Default logging status, true turns logging on.
# ex: logging = true|false
#
logging = false
#
# Logfile, the default siege logfile is $PREFIX/var/siege.log
# This directive allows you to choose an alternative log file.
# Environment variables may be used as shown in the examples:
# ex: logfile = /home/jeff/var/log/siege.log
# logfile = ${HOME}/var/log/siege.log
# logfile = ${LOGFILE}
#
# logfile =
#
# HTTP protocol. Options HTTP/1.1 and HTTP/1.0.
# Some webservers have broken implementation of the
# 1.1 protocol which skews throughput evaluations.
# If you notice some siege clients hanging for
# extended periods of time, change this to HTTP/1.0
# ex: protocol = HTTP/1.1
# protocol = HTTP/1.0
#
protocol = HTTP/1.1
#
# Default number of simulated concurrent users
# ex: concurrent = 25
#
concurrent = 15
3.PERFORMANCE STATISTICS report
Performance statistics report is printed in console to indicate the performance about Server, and is to be printed when finished all the web traffic. Following is the report of an example:
bdong@bdong-desktop:/etc/siege$ siege -c 200 -r 2 www.163.com
done.
Transactions: 596 hits
// 完成596次处理,在web性能测试中,一个事务表示一个“从用户->web Server->DB->web server->用户”的过程,一般的响应时间都是针对事务而言的。
Availability: 99.33 %
// 成功率
Elapsed time: 122.48 secs
// 总共用时
Data transferred: 30.94 MB
// 共数据传输: 30.94
Response time: 12.79 secs
// 响应用时12.79 秒:显示网络连接的速度响应时间指的是从客户端发起一个请求开始,到客户端接收到从服务器端返回的响应结束,这个过程所耗费的时间。在某些工具中,响应时 间通常会称为 “TTLB”,即“time to last byte”,意思是从发起一个请求开始,到客户端收到最后一个字节的响应所耗费的时间。响应时间的单位一般为“秒”或者“毫秒”。一个公式可以表示:响应 时间= 网络响应时间 + 应用程序响应时间
Transaction rate: 4.87 trans/sec
// 平均每秒完成4.87次处理:表示服务器后台处理的速度
Throughput: 0.25 MB/sec
// 平均每秒传送数据:0.25MB,吞吐量指的是单位时间内处理的客户端请求数量。通常情况下,吞吐量用请求数/秒或者页面数/秒来衡量。从业务角度看,吞吐量也可以用访问人数/天 或者页面访问量/天 来衡量。 [www.S
Concurrency: 62.22
// 最高并发数 62.22,并发数是指同时进行请求的客户的数量,并发数用于模拟用户的真实负载情况(并发情况是对系统最大的考验),并发数≠同时使用系统的用户数。
Successful transactions: 596
// 成功处理次数
Failed transactions: 4
// 失败处理次数
Longest transaction: 118.94
secs //每次传输所花最长时间118.94
Shortest transaction: 0.38
secs //每次传输所花最短时间0.38
Beside this basic instruction, you can read Siege manual to master Siege more skill to control your test.
4. Testing Example
4.1 test web server performance
This example just to let you to be familiar with Siege, So we simulate 20 user to access http://www.*.com/tech/
, and 2 times per user. Following is to test http://www.*.com/tech/
Server’s performance.
siege.2009-08-04T09:56+0800 siegerc urls.txt
bdong@bdong-desktop:/etc/siege$ pwd
/etc/siege
bdong@bdong-desktop:/etc/siege$ cat urls.txt
# URLS file for siege
# --
# Format the url entries in any of the following formats:
# http://www.whoohoo.com/index.html
# http://www/index.html
# www/index.html
# http://www.whoohoo.com/cgi-bin/howto/display.cgi?1013
# Use the POST directive for pages that require it:
# http://www.whoohoo.com/cgi-bin/haha.cgi POST ha=1&ho=2
# or POST content from a file:
# http://www.whoohoo.com/melvin.jsp POST </home/jeff/haha
# http://www.whoohoo.com/melvin.jsp POST <./haha
# You may also set and reference variables inside this file,
# for more information, man urls_txt
# -------------------------------------------------------
http://www.*.com/tech/
http://www.*.com/tech/acdsee.html
http://www.*.com/tech/ant.html
http://www.*.com/tech/apache_install.html
http://www.*.com/tech/awstats.html
http://www.*.com/tech/cache.html
http://www.*.com/tech/click.html
http://www.*.com/tech/cms.html
http://www.*.com/tech/compress.html
http://www.*.com/tech/cvs_card.html
http://www.*.com/tech/default.html
http://www.*.com/tech/dev.html
http://www.*.com/tech/gnu.html
bdong@bdong-desktop:/etc/siege$ siege -c 20 -r 2 -f urls.txt
** SIEGE 2.66
** Preparing 20 concurrent users for battle.
The server is now under siege...
HTTP/1.0 200 0.14 secs: 54592 bytes ==> /
....
HTTP/1.0 200 0.02 secs: 1745 bytes ==> /
HTTP/1.0 200 0.01 secs: 1745 bytes ==> /
HTTP/1.0 200 3.01 secs: 1745 bytes ==> /
done.
Transactions: 40 hits
Availability: 100.00 %
Elapsed time: 4.16 secs
Data transferred: 1.07 MB
Response time: 0.36 secs
Transaction rate: 9.62 trans/sec
Throughput: 0.26 MB/sec
Concurrency: 3.45
Successful transactions: 40
Failed transactions: 0
Longest transaction: 3.01
Shortest transaction: 0.01
FILE: /var/siege.log
You can disable this annoying message by editing
the .siegerc file in your home directory; change
the directive 'show-logfile' to false.
Error: unable to create log file: Permission denied
bdong@bdong-desktop:/etc/siege$
WEB 性能测试的部分概念一般来说,一个请求的处理包括以下步骤:
(1 )客户发送请求; [ 内容来自" 岁月联盟"]
(2 ) server 接受到请求,进行处理;
(3 )web server 向DB 获取数据;
(4 )web server 生成用户请求的object (页面),返回给用户。从客户发送请求开始到客户接收到最后一个字节的时间成为响应时间(第三步不包括在每次请求处理中)。
1. 事务(Transaction )
在web 性能测试中,一个事务表示一个“从用户->web Server ->DB ->web server -> 用户”的过程,一般的响应时间都是针对事务而言的。
2. 响应时间
响应时间指的是从客户端发起一个请求开始,到客户端接收到从端返回的响应结束,这个过程所耗费的时间。在某些工具中,响应时间通常会称为 “TTLB” ,即“time to last byte” ,意思是从发起一个请求开始,到客户端收到最后一个字节的响应所耗费的时间。响应时间的单位一般为“秒”或者“毫秒”。一个公式可以表示:响应 时间= 网络响应时间 + 应用程序响应时间
3. 并发数
并发数是指同时进行请求的客户的数量,并发数用于模拟用户的真实负载情况(并发情况是对系统最大的考验),并发数≠同时使用系统的用户数。 信息来自" 岁月联盟"
4. 吞吐量 [" 岁月联盟"]
吞吐量指的是单位时间内处理的客户端请求数量。通常情况下,吞吐量用请求数/ 秒或者页面数/ 秒来衡量。从业务角度看,吞吐量也可以用访问人数/ 天 或者页面访问量/ 天 来衡量。 [www.Syue.com]
5. 利用率
资源利用率指的是对不同系统资源的使用程度,例如服务器的CPU (s ),内存,网络带宽等。资源利用率通常以占用最大值的百分比 n % 来衡量。