1、http_loadphp
程序很是小,解压后也不到100Khtml
http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载。可是它不一样于大多数压力测试工mysql
具,它能够以一个单一的进程运行,通常不会把客户机搞死。还能够测试HTTPS类的网站请求。web
下载地址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gzsql
安装很简单apache
tar zxvf http_load-12mar2006.tar.gz cd http_load-12mar2006 make && make install
命令格式:服务器
http_load -p 并发访问进程数 -s 访问时间 须要访问的URL文件
参数其实能够自由组合,参数之间的选择并无什么限制。好比你写成http_load -parallel 5 -seconds 300 urls.txt也是能够的。咱们把参数给你们简单说明一下。cookie
-parallel 简写-p :含义是并发的用户进程数。 -fetches 简写-f :含义是总计的访问次数 -rate 简写-p :含义是每秒的访问频率 -seconds简写-s :含义是总计的访问时间
准备URL文件:urllist.txt,文件格式是每行一个URL,URL最好超过50-100个测试效果比较好,文件格式网络
以下:并发
http://www.vpser.net/uncategorized/choose-vps.html http://www.vpser.net/vps-cp/hypervm-tutorial.html http://www.vpser.net/coupons/diavps-april-coupons.html http://www.vpser.net/security/vps-backup-web-mysql.html
例如:
http_load -p 30 -s 60 urllist.txt
参数了解了,咱们来看运行一条命令来看看它的返回结果
命令:./http_load -rate 5 -seconds 10 urllist.txt说明执行了一个持续时间10秒的测试,每秒的频率为5。
49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds5916 mean bytes/connection4.89274 fetches/sec, 28945.5 bytes/secmsecs/connect: 28.8932 mean, 44.243 max, 24.488 minmsecs/first -response: 63.5362 mean, 81.624 max, 57.803 minHTTP response codes: code 200 — 49
结果分析:
特殊说明:
2、webbench
webbench是Linux下的一个网站压力测试工具,最多能够模拟3万个并发链接去测试网站的负载能力。下载地址能够到google搜,我这里给出一个
下载地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
这个程序更小,解压后不到50K,呵呵
安装很是简单
tar zxvf webbench-1.5.tar.gz cd webbench-1.5make && make install
会在当前目录生成webbench可执行文件,直接可使用了
用法:
webbench -c 并发数 -t 运行测试时间 URL
如:
webbench -c 5000 -t 120 http://www.vpser.net
3、ab
ab是apache自带的一款功能强大的测试工具
安装了apache通常就自带了
用法能够查看它的说明
$ ./ab ./ab: wrong number of arguments Usage: ./ab [options] [http://]hostname[:port]/path Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make -t timelimit Seconds to max. wait for responses -p postfile File containing data to POST -T content-type Content-type header for POSTing -v verbosity How much troubleshooting info to print -w Print out results in HTML tables -i Use HEAD instead of GET -x attributes String to insert as table attributes -y attributes String to insert as tr attributes -z attributes String to insert as td or th attributes -C attribute Add cookie, eg. ‘Apache=1234. (repeatable) -H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’ Inserted after all normal header lines. (repeatable) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. -P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password. -X proxy:port Proxyserver and port number to use -V Print version number and exit -k Use HTTP KeepAlive feature -d Do not show percentiles served table. -S Do not show confidence estimators and warnings. -g filename Output collected data to gnuplot format file. -e filename Output CSV file with percentages served -h Display usage information (this message)
参数众多,通常咱们用到的是-n和-c
例如:
./ab -c 1000 -n 100 http://www.vpser.net/index.php
这个表示同时处理1000个请求并运行100次index.php文件.
4、Siege
一款开源的压力测试工具,能够根据配置对一个WEB站点进行多用户的并发访问,记录每一个用户全部请求过程的相应时间,并在必定数量的并发访问下重复进行。
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 //每次传输所花最短期
5、利用autobench工具结合httperf命令对web服务器进行测试,得出该服务器能够承载的最大并发链接数与最佳并发数。
一、Httperf
httperf是一款高性能的HTTP测试工具,使用它咱们能够准肯定位服务器的并发链接能力。下面介绍一下它的主要特征
下载:http://code.google.com/p/httperf/downloads/list
安装:
tar xvzf httperf-0.9.0.tar.gz cd httperf-0.9.0 ./configure make && make install
更多的使用方法参见man page。
二、autobench
autobench是一款基于httperf的Perl脚本。它会在一次测试中调用屡次httperf来对web服务器进行测试,每次会按照给定的参数增长并发链接数,将 httperf的测试结果保存为CSV格式的文件,该文件能够被Excel直接读取,方便生成测试报告。借助于autobench自带的 bench2graph工具能够生成漂亮的测试结果对比图
参考:
http://blog.51cto.com/510512/740219(以上内容转自此篇文章)