LINUX下的压力工具

4 篇文章 0 订阅
2 篇文章 0 订阅

一,http_load

1,获取安装包

我从网上走的地址是这个,http://acme.com/software/http_load/http_load-12mar2006.tar.gz

2,解压

tar zxvf http_load-12mar2006.tar.gz

3, cd http_load-12mar2006/

4,执行 make

由于makeinstall就需要root权限了,但是只要执行了make不安装/use/bin(不执行 make install)也可是以直接使用http_load的,所以只为简单使用,就不需要执行make install了。

Httpload使用也很方便的,用法介绍如下

usage:  ./http_load[-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sipsip_file]

            -parallelN | -rate N [-jitter]

            -fetchesN | -seconds N

            url_file

One start specifier, either -parallel or -rate, isrequired.

One end specifier, either -fetches or -seconds, isrequired.

 

-parallel 简写-p :含义是并发的用户进程数。
-rate    简写-p :含义是每秒的访问频率
-seconds简写-s :含义是总计的访问时间

-fetches 简写-f :含义是总计的访问次数

使用的时候 –parallel –rate二选一,-second和-feches二选一 ,url_file就是需要访问的URL文本文件,文件格式是每行一个URL,传说URL最好超过50-100个测试效果比较好。

例如: ./http_load  -parallel 100-fetches 2000 urlfile 就表示并发100,进行总计2000次访问的压力测试。

如下是我的一个测试的结果:

$./http_load  -parallel 100 -fetches 2000url   

2000fetches, 100 max parallel, 0 bytes, in 4.01425 seconds

0 meanbytes/connection

498.225fetches/sec, 0 bytes/sec

msecs/connect:1.09737 mean, 1.593 max, 0.671 min

msecs/first-response:117.131 mean, 4011.51 max, 11.014 min

HTTPresponse codes:

code 200 --2000

$

结果看出,总计进行了2000次的访问,最大的并发是100,总共传递数据是0,总过耗时4.01425,‘0mean bytes/connection’表示每一传输的数据是‘0,498.225fetches/sec, 0 bytes/sec’表示每秒处理的请求是498.225个,每秒传递数据是0,‘msecs/connect: 1.09737 mean, 1.593 max, 0.671min’表示每连接的平均访问时间是1.09737ms,最大的是1.593ms,最小的是0.671ms,‘code 200 --2000’说明打开页面的访问类型,如果403的类型过多,那可能要注意是否系统遇到了瓶颈。

说明:一般会关注到的指标是fetches/sec、msecs/connect

他们分别对应的常用性能指标参数

Qpt-每秒响应用户数和responsetime,每连接响应用户时间。

测试的结果主要也是看这两个值。

当 然仅有这两个指标并不能完成对性能的分析,我们还需要对服务器的cpu、memory进行分析,才能得出结论,另外,测试结果中主要的指标是 fetches/sec 这个选项,即服务器每秒能够响应的查询次数,用这个指标来衡量性能。似乎比 apache的ab准确率要高一些,也更有说服力一些。


http_load测试参数比较 
./http_load -parallel 200 -seconds 10 urls 
按照固定时间来结束测试,这样可以比较相同时间内被测服务器的响应速度. 
./http_load -parallel 200 -fetches 1000 urls 
按照固定申请数来测试,这样可以比较相同访问量下返回的响应速度. 
虽然两者都可以获取到服务器的响应速度 
但是使用fetches更容易让被测服务器收到压力 
由于seconds控制测试时间,很有可能在短时间内测试客户端并没有发起足够数量的请求 
而服务端在收到足够压力之前,测试就已经结束了. 
有一些情况,诸如内存泄漏以及资源回收不利或者对后面的响应速度越来越慢等情况 
在这种测试条件下不容易发生 
而使用fetchs,能够让客户端保证确定请求数的全部处理. 
使用时间作为控制参数 
会由于测试人员不够耐心而人为将seconds参数设置过小 
导致测试结果失去意义 
所以,最后建议使用fetches作为测试参数.用以作为基准进行比较 


二、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.5
#make && make install
会在当前目录生成webbench可执行文件,直接可以使用了

用法:

webbench -c 并发数 -t 运行测试时间 URL
如:
webbench -c 5000 -t 120 http://www.vpser.net /

三、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文件.
四、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 //每次传输所花最短时间


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值