ferragamo shoes timberland outlet tory burch north face coats Timberland Sale paul smith bags Paul Smith handbag dsquared sale tods UK
三种web性能压力测试工具http_load webbench ab Siege « So Tired!_!

2012年01月17日

三种web性能压力测试工具http_load webbench ab Siege

by Nick Xu — Categories: LinuxLeave a comment

http_load

下载地址:http://www.acme.com/software/http_load/http_load-12mar2006.tar.gz

http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载。但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把客户机搞死。可以可以测试HTTPS类的网站请求。

命令格式:http_load  -p 并发访问进程数  -s 访问时间  需要访问的URL文件
参数介绍

        -p 并发访问进程数

        -f 总的访问次数

        -r 每秒的访问频率

        -s 总的访问时间

通常参数组合:-p –f;-r -s

引用
http_load -p 30 -s 60  urllist.txt准备URL文件:tst.list,文件格式是每行一个URL,URL最好超过50-100个测试效果比较好,另外,测试结果中主要的指标是 fetches/sec 这个选项,即服务器每秒能够响应的查询次数,用这个指标来衡量性能

 

引用
% ./http_load -rate 10 -seconds 60 urllist.txt
49 fetches, 4 max parallel, 289884 bytes, in 10.0148 seconds
5916 mean bytes/connection
4.89274 fetches/sec, 28945.5 bytes/sec
msecs/connect: 28.8932 mean, 44.243 max, 24.488 min
msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min

4.89274 fetches/sec 这个值得就是说服务器每秒能够响应的查询次数为4.8左右
这个值得是根据 49 fetches / 10.0148 seconds 秒计算出来的


webbench
webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。
下载地址:

http://cid-9601b7b7f2063d42.skydrive.live.com/self.aspx/Public/webbench-1.5.tar.gz

安装
#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install
会在当前目录生成webbench可执行文件,直接可以使用了

用法:
webbench -c 并发数 -t 运行测试时间 URL
如:webbench -c 5000 -t 120 http://www.askwan.com


ab 

ab是Apache服务器自己带的性能测试工具,用它可以对指定的URL进行模拟访问,然后生成一份有关访问效率的报表,从中可以大概看出网站在高压力情况下的表现。

Windows下的ab.exe一般都在Apache安装目录的bin目录下。这里举几个我实际中用过的例子:

对http://localhost/dz7/index.php产生400次请求
ab -n 400 http://localhost/dz7/index.php
测试完成后,ab会输出测试的结果:

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests

Server Software:        Apache/2.2.11
Server Hostname:        localhost
Server Port:            80

Document Path:          /dz7/index.php
Document Length:        7015 bytes

Concurrency Level:      1
Time taken for tests:   21.623 seconds
Complete requests:      400
Failed requests:        399
   (Connect: 0, Receive: 0, Length: 399, Exceptions: 0)
Write errors:           0
Total transferred:      2968811 bytes
HTML transferred:       2805205 bytes
Requests per second:    18.50 [#/sec] (mean)
Time per request:       54.057 [ms] (mean)
Time per request:       54.057 [ms] (mean, across all concurrent requests)
Transfer rate:          134.08 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0      16
Processing:    31   54  64.5     47    1265
Waiting:       16   51  64.3     47    1250
Total:         31   54  64.5     47    1265

Percentage of the requests served within a certain time (ms)
  50%     47
  66%     47
  75%     47
  80%     47
  90%     47
  95%     62
  98%    141
  99%    187
 100%   1265 (longest request)

参数-n设定请求的次数;另外,还可以用-c来设定并发访问数,例如要模拟50个并发访问,可以用
ab -n 400 -c 50 http://localhost/dz7/index.php

此外,还有一个实际的问题,就是如何用ab来模拟已登录的用户的访问。绝大部分程序的登录机制都是用Cookie+Session来实现的,浏览器在每次请求时都发送一个Cookie,里面记录了Session的SID。你可以先在利用Firefox的Firebug插件来确定Cookie里的内容是什么。
firebug_cookie
从中可以看到表示登录用户的内容是“QfI_sid=55ySsk”。ab可以用-C(大写的C)来设定每次请求用发送的Cookie。所以
ab -n 400 -c 50 -C "QfI_sid=55ySsk" http://localhost/dz7/index.php
就可以模拟已登录用户的400次访问,并发数为50的情况。

最后再透露一个绝技:
ab --help

 

四、Siege
一款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。
官方:http://www.joedog.org/
Siege下载:http://soft.vpser.net/test/siege/siege-2.67.tar.gz
解压:
# tar -zxf siege-2.67.tar.gz
进入解压目录:
# cd siege-2.67/
安装:
#./configure ; make
#make install

使用
siege -c 200 -r 10 -f example.url
-c是并发量,-r是重复次数。 url文件就是一个文本,每行都是一个url,它会从里面随机访问的。

example.url内容:

http://www.licess.cn
http://www.vpser.net
http://soft.vpser.net

结果说明
Lifting the server siege… done.
Transactions: 3419263 hits //完成419263次处理
Availability: 100.00 % //100.00 % 成功率
Elapsed time: 5999.69 secs //总共用时
Data transferred: 84273.91 MB //共数据传输84273.91 MB
Response time: 0.37 secs //相应用时1.65秒:显示网络连接的速度
Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次处理:表示服务器后
Throughput: 14.05 MB/sec //平均每秒传送数据
Concurrency: 213.42 //实际最高并发数
Successful transactions: 2564081 //成功处理次数
Failed transactions: 11 //失败处理次数
Longest transaction: 29.04 //每次传输所花最长时间
Shortest transaction: 0.00 //每次传输所花最短时间

anyShare分享到:
          

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

© 2012 So Tired!_! All rights reserved - Wallow theme v0.46.4 by ([][]) TwoBeers - Powered by WordPress - Have fun!
$1.99 Domains* at GoDaddy.com
֩` ֩` `ȥ Moncler Jackets Moncler Jackets Sale ֩` Moncler Monclair Moncler On Sale Moncler Online Outlet Moncler For Sale Monclers For Cheap Moncler Stores Moncler Cheap Authentic Moncler Jackets Moncler Outlets "Genuine Ugg Boots" Moncler Store moncler buy Moncler Jacket Down Down Jacket Moncler monclerforkids Moncler It Shop Moncler Uk Moncler Moncler Ski Mens Down Coat Jackets And Coats LeatherJackets For Men Real Ugg Boots "Classic Short Ugg Boots"
Abercrombie Sale Abercrombie Outlet Abercrombie Sale Abercrombie Jackets North Face Outlet ferragamo north face coat north face clothes ferragamo shoes timberland outlet spyder jackets paul smith spyder jacket salvatore ferragamo outlet spyder ski jacket tory burch sale Timberland Boots sale