我也搞搞在线测试2-siege和ab

中秋节快来了,现在想的事情就是出去好好放松下,长这么大从来没有自己主动的出去旅游过,借着这个机会,出去转转...

系统环境: CentOS 5.4 x86_84

首先安装epel源,方便安装siege

[root@cnc ~]#wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@cnc ~]#rpm -ivh epel-release-5-4.noarch.rpm
[root@cnc ~]# yum -y install siege

玩玩siege:

1.准备测试的url,如下

[root@cnc ~]# cat url.txt
http://218.9.147.201/n/7/2286/2675/76391943.hlv
http://218.9.147.201/n/6/539/1340/133179932.hlv
http://218.9.147.201/n/7/2286/2675/76391943.hlv
http://218.9.147.201/n/5/627/2934/71281857.hlv
http://218.9.147.201/n/4/183/840/76194253.hlv
http://218.9.147.201/n/2/611/750/64989806.hlv

2.开始测试

[root@cnc ~]# siege -c 300 -r 1 -f url.txt
-c 是并发量,-r 是重复次数,urls.txt是一个文本文件(每行一个url,siege会从里面随机访问)

3.测试结束,看测试数据

Transactions:                    300 hits //完成300次请求
Availability:                 100.00 % //100.00% 成功率
Elapsed time:                  38.07 secs // 总共使用时间
Data transferred:            2139.38 MB //共数据传输2139.38 MB
Response time:                 29.18 secs // 响应时间,显示网络连接速度
Transaction rate:               7.88 trans/sec //平均每秒完成7.88次处理
Throughput:                    56.20 MB/sec //平均每秒传输数据
Concurrency:                  229.96 //实际最高并发连接数
Successful transactions:         300 // 成功处理次数
Failed transactions:               0 //失败次数
Longest transaction:           38.05 //每次传输所花最长时间
Shortest transaction:          11.86 //每次传输所花最短时间

参考资料:http://www.ha97.com/4663.html


玩玩ab:

1.centos安装ab

[root@cnc peiqiang]#yum -y install httpd-tools

2.测试

[root@cnc peiqiang]#ab -kc 10 -n 10 http://218.9.147.201/n/7/2286/2675/76391943.hlv
-k使用keepalive,-c 并发数,-n 总共的请求数

[root@cnc peiqiang]# ab -kc 10 -n 10 http://218.9.147.201/n/7/2286/2675/76391943.hlv
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 218.9.147.201 (be patient).....done

Server Software:        nginx/1.5.3
Server Hostname:        218.9.147.201
Server Port:            80

Document Path:          /n/7/2286/2675/76391943.hlv
Document Length:        7477676 bytes

Concurrency Level:      10 //并发数
Time taken for tests:   1.767 seconds //整个测试持续的时间 
Complete requests:      10 //完成的请求数量
Failed requests:        0 //失败的请求数量
Write errors:           0
Keep-Alive requests:    10 //长链接数
Total transferred:      111337644 bytes //整个场景中的网络传输量
HTML transferred:       111332723 bytes //整个场景中的HTML内容传输量
Requests per second:    5.66 [#/sec] (mean) //每秒事务数
Time per request:       1767.478 [ms] (mean) //平均事务响应时间
Time per request:       176.748 [ms] (mean, across all concurrent requests) //它反映了完成一个请求需要的平均时间,在当前的并发情况下,增加一个请求需要的时间
Transfer rate:          61516.00 [Kbytes/sec] received //传输速率

//网络上消耗的时间的分解
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10  12.7      0      26
Processing:   288  606 463.2    603    1744
Waiting:       24   41  21.2     31      79
Total:        288  616 470.0    626    1767

//整个场景中所有请求的响应情况,如50%的用户小于626毫秒
Percentage of the requests served within a certain time (ms)
  50%    626
  66%    648
  75%    658
  80%    992
  90%   1767
  95%   1767
  98%   1767
  99%   1767
 100%   1767 (longest request)

参考资料:http://www.nginx.cn/110.html

自言自语:

siege和ab比较简单,测试时就那几个参数改改,当然这样测试的准确性也没有tcpcopy高了。