2023拉

压力测试工具集合【ab,webbench,Siege,http_load,Web Application Stress】转

上一篇 / 下一篇  2013-10-22 17:07:13 / 个人分类:开源测试工具

http://bbs.linuxtone.org/thread-62-1-1.html

http://bbs.linuxtone.org/thread-62-1-1.html

loadrunner

ab

==================1.autobench结合httperf可以画出很漂亮的分析图
下载网址:http://www.xenoclast.org/autobench/
autobench --single_host --host1www.test.com--uri1 /10K --quiet \
--low_rate 20 --high_rate 200 --rate_step 20 --num_call 10 \
--num_conn 5000 --timeout 5 --file results.tsv


=============2.Siege 功能强大的压力测试软件
http://www.joedog.org/JoeDog/Siege
操作手册:http://www.joedog.org/Siege/Manual

-c 500 并发500个用户
-r 150 重复循环150次
-f sites.list 任务的URL列表

其它实用参数:

-i 随机 URL ,默认是从列表的上面到下面来打压力
-b 进行压力测试,不进行延时
-t 持续时间,即测试持续时间,在NUM时间后结束,单位默认为分


Siege 修正参数进行压力测试

./siege -c 500 -r 150 -f sites.list -i -b
复制代码



=====================3.webbench web/proxy测试软件,相当不错!


http://home.tiscali.cz:8080/~cz210552/webbench.html
http://www.ibiblio.org/pub/Linux ... webbench-1.5.tar.gz


==================4.sysbench 数据库压力测试不错的软件,当你mysql调优以后不防有这个压压测试一下


http://sysbench.sourceforge.net/
sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。
它主要包括以下几种方式的测试:
1、cpu性能
2、磁盘io性能
3、调度程序性能
4、内存分配及传输速度
5、POSIX线程性能
6、数据库性能(OLTP基准测试)
目前sysbench主要支持 MySQL,pgsql, oracle 这3种数据库。


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
http://www.opensourcetesting.org/performance.php

一、webbench
Web-bench is a simple web server benchark.
Web Bench is very simple tool for benchmarking WWW or proxy servers. Uses fork() for simulating multiple clients and can use HTTP/0.9-HTTP/1.1 requests.
This benchmark is not very realistic, but it can test if your HTTPD can realy handle that many clients at once (try to run some CGIs) without taking your machine down.
Displays pages/min and bytes/sec. Can be used in more aggressive mode with -f switch.
What's New in This Release:

# tar zxvf webbench-1.5.tar.gz
# cd webbench-1.5
# make && make install

#webbench -c 500 -t 30
参数说明:-c表示并发数,-t表示时间(秒)

二、Siege:压力模拟/测试工具

最早使用的压力测试工具是apache的ab(apache benchmark),apache ab做重复压力测试不错,但是每次只能测试一个链接,如何测试一组链接(比如从日志中导出的1个小时的日志,做真实压力测试),后来找到了这个:
Siege是一个压力测试和评测工具,设计用于WEB开发这评估应用在压力下的承受能力:可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。

SIEGE is an http regressive testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress, to see how it will stand up to load on the internet. It lets the user hit a webserver with a configurable number of concurrent simulated users. Those users place the webserver "under siege." The duration of the siege is measured in transactions, the sum of simulated users and the number of times each simulated user repeats the process of hitting the server. Thus 20 concurrent users 50 times is 1000 transactions, the length of the test.

下载/安装
Siege时一个开放源代码项目:http://www.joedog.org

下载:
wgetftp://sid.joedog.org/pub/siege/siege-latest.tar.gz

安装:
# ./configure
#make && make install

siege包含了一组压力测试工具:
SIEGE (1) Siege是一个HTTP压力测试和评测工具.
使用样例:
任务列表:www.chedong.com.url文件
http://www.chedong.com/tech/
http://www.chedong.com/tech/acdsee.html
http://www.chedong.com/tech/ant.html
http://www.chedong.com/tech/apache_install.html
http://www.chedong.com/tech/awstats.html
http://www.chedong.com/tech/cache.html
http://www.chedong.com/tech/click.html
http://www.chedong.com/tech/cms.html
http://www.chedong.com/tech/compress.html
http://www.chedong.com/tech/cvs_card.html
http://www.chedong.com/tech/default.html
http://www.chedong.com/tech/dev.html
http://www.chedong.com/tech/gnu.html
....

# siege -c 20 -r 2 -fwww.sina.com.cn
参数说明:
-c 20 并发20个用户
-r 2 重复循环2次
-fwww.chedong.com.url任务列表:URL列表

输出样例:

** Siege 2.59
** Preparing 20 concurrent users for battle. 这次“战斗”准备了20个并发用户
The server is now under siege.. done. 服务在“围攻”测试中:
Transactions: 40 hits 完成40次处理
Availability: 100.00 % 成功率
Elapsed time: 7.67 secs 总共用时
Data transferred: 877340 bytes 共数据传输:877340字节
Response time: 1.65 secs 相应用时1.65秒:显示网络连接的速度
Transaction rate: 5.22 trans/sec 平均每秒完成5.22次处理:表示服务器后台处理的速度
Throughput: 114385.92 bytes/sec 平均每秒传送数据:114385.92字节
Concurrency: 8.59 最高并发数 8.59
Successful transactions: 40 成功处理次数
Failed transactions: 0 失败处理次数

注意:由于速度很快,可能会达不到并发速度很高就已经完成。Response time显示的是测试机器和被测试服务器之间网络链接状况。Transaction rate则表示服务器端任务处理的完成速度。

辅助工具:
增量压力测试:

为了方便增量压力测试,siege还包含了一些辅助工具:
bombardment (1)
是一个辅助工具:用于按照增量用户压力测试:
使用样例:
bombardment urlfile.txt 5 3 4 1
初始化URL列表:urlfile.txt
初始化为:5个用户
每次增加:3个用户
运行:4次
每个客户端之间的延迟为:1秒

输出成CSV格式:
siege2csv.pl (1)
siege2csv.pl将bombardment的输出变成CSV格式:
Time Data Transferred Response Time Transaction Rate Throughput Concurrency Code 200 (note that this is horribly broken.)
242 60.22 603064 0.02 4.02 10014.35 0.08
605 59.98 1507660 0.01 10.09 25136.05 0.12
938 59.98 2337496 0.02 15.64 38971.26 0.26
1157 60 2883244 0.04 19.28 48054.07 0.78


网络IO性能测试:http://bbs.linuxtone.org/thread-5437-1-1.html
httpload:http://bbs.linuxtone.org/thread-2899-1-2.html
http://bbs.linuxtone.org/thread-1097-1-2.html

--------------------------------------------------1 Apache附带的工具ab

ab的全称是ApacheBench,是Apache附带的一个小工具,专门用于HTTP Server的benchmark testing,可以同时模拟多个并发请求。

在这个例子的一开始,我执行了这样一个命令ab -n 10 -c 10http://www.google.com/。这个命令的意思是启动ab,向www.google.com发送10个请求(-n 10) ,并每次发送10个请求(-c 10)——也就是说一次都发过去了。

apache ab做重复压力测试不错,但是每次只能测试一个链接



D:\apahce\bin>ab.exe -n 10 -c 10 http://www.google.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.google.com (be patient).....done


Server Software: gws
Server Hostname: www.google.com
Server Port: 80

Document Path: /
Document Length: 4941 bytes

Concurrency Level: 10
Time taken for tests: 5.218750 seconds//**整个测试持续的时间**
Complete requests: 10//**完成的请求数量**
Failed requests: 9//**失败的请求数量**

(Connect: 0, Length: 9, Exceptions: 0)
Write errors: 0
Total transferred: 52730 bytes**整个场景中的网络传输量**
HTML transferred: 49540 bytes**整个场景中的HTML内容传输量**
Requests per second: 1.92 [#/sec] (mean) **大家最关心的指标之一,相当于LR中的每秒事务数,后面括号中的mean表示这是一个平均值**
Time per request: 5218.750 [ms] (mean) *大家最关心的指标之二,相当于LR中的平均事务响应时间,后面括号中的mean表示这是一个平均值**

Time per request: 521.875 [ms] (mean, across all concurrent requests)
Transfer rate: 9.77 [Kbytes/sec] received*平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题**

Connection Times (ms)
min mean[+/-sd] median max
Connect: 187 488 257.6 437 921
Processing: 312 1673 1204.4 1547 3985
Waiting: 296 1668 1206.3 1546 3984
Total: 593 2162 1432.6 1890 4906
**下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于**毫秒,60%的用户响应时间小于**毫秒,最大的响应时间小于 **毫秒**
Percentage of the requests served within a certain time (ms)
50% 1890
66% 2406
75% 3093
80% 3984
90% 4906
95% 4906
98% 4906
99% 4906
100% 4906 (longest request)

--------------------------------------------------------------------实际测试

Server Software: Apache/2.2.3
Server Hostname: www.netnov.cn
Server Port: 80

Document Path: /
Document Length: 18958 bytes

Concurrency Level: 10
Time taken for tests: 8.949 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1912100 bytes
HTML transferred: 1895800 bytes
Requests per second: 11.17 [#/sec] (mean)
Time per request: 894.906 [ms] (mean)
Time per request: 89.491 [ms] (mean, across all concurrent requests)
Transfer rate: 208.66 [Kbytes/sec] received


Connection Times (ms)
min mean[+/-sd] median max
Connect: 78 87 8.9 94 109
Processing: 219 752 122.2 781 875
Waiting: 219 510 179.9 515 843
Total: 312 839 121.3 859 953

Percentage of the requests served within a certain time (ms)
50% 859
66% 859
75% 875
80% 890
90% 921
95% 937
98% 953
99% 953
100% 953 (longest request)

-----------------------------------------------------------------------------


格式: ./ab [options] [http://]hostname[:port]/path
参数:
-n requests Number of requests to perform
//在测试会话中所执行的请求个数。默认时,仅执行一个请求
-c concurrency Number of multiple requests to make
//一次产生的请求个数。默认是一次一个。
-t timelimit Seconds to max. wait for responses
//测试所进行的最大秒数。其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-p postfile File containing data to POST
//包含了需要POST的数据的文件.
-T content-type Content-type header for POSTing
//POST数据所使用的Content-type头信息。
-v verbosity How much troubleshooting info to print
//设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。 -V 显示版本号并退出。
-w Print out results in HTML tables
//以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。
-i Use HEAD instead of GET
// 执行HEAD请求,而不是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)
//-C cookie-name=value 对请求附加一个Cookie:行。 其典型形式是name=value的一个参数对。此参数可以重复。
-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.
//-P proxy-auth-username:password 对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。
-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)

-------------------------------------------------2 webbench

wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
tar zxvf webbench-1.5.tar.gz
cd webbench-1.5
make && make install

#webbench -c 100 -t 10 http://192.168.200.100/info.php

参数说明:-c表示并发数,-t表示持续时间(秒)

root@ubuntu-desktop:/etc/nginx/sites-available# webbench -c 100 -t 10 http://192.168.200.100/info.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.200.100/info.php
100 clients, running 10 sec.

Speed=19032 pages/min, 18074373 bytes/sec.
Requests: 3172 susceed, 0 failed.

-----------------------------------------------------------3 Siege

apache ab做重复压力测试不错,但是每次只能测试一个链接

如何测试一组链接(比如从日志中导出的1个小时的日志,做真实压力测试),后来找到了这个:
Siege是一个压力测试和评测工具,设计用于WEB开发这评估应用在压力下的承受能力:可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。


下载/安装
Siege时一个开放源代码项目:http://www.joedog.org/siege/

下载:
wget ftp://sid.joedog.org/pub/siege/siege-latest.tar.gz

安装:
#./configure ; make
#make install

#siege -help (如果有help出现,则已经安装成功)

siege包含了一组压力测试工具:
SIEGE (1) Siege是一个HTTP压力测试和评测工具.
使用样例:
任务列表:www.chedong.com.url文件
http://www.chedong.com/tech/
http://www.chedong.com/tech/acdsee.html
http://www.chedong.com/tech/ant.html
http://www.chedong.com/tech/apache_install.html
http://www.chedong.com/tech/awstats.html
http://www.chedong.com/tech/cache.html
http://www.chedong.com/tech/click.html
http://www.chedong.com/tech/cms.html
http://www.chedong.com/tech/compress.html
http://www.chedong.com/tech/cvs_card.html
http://www.chedong.com/tech/default.html
http://www.chedong.com/tech/dev.html
http://www.chedong.com/tech/gnu.html
….


siege -c 20 -r 2 -f www.chedong.com.url
参数说明:
-c 20 并发20个用户
-r 2 重复循环2次
-f www.chedong.com.url 任务列表:URL列表

输出样例:

** Siege 2.59
**Preparing 20 concurrent users for battle. 这次“战斗”准备了20个并发用户
The server is now under siege.. done. 服务在“围攻”测试中:
Transactions: 40 hits 完成40次处理
Availability: 100.00 % 成功率
Elapsed time: 7.67 secs 总共用时
Data transferred: 877340 bytes 共数据传输:877340字节
Response time: 1.65 secs 相应用时1.65秒:显示网络连接的速度
Transaction rate: 5.22 trans/sec 平均每秒完成5.22次处理:表示服务器后台处理的速度
Throughput: 114385.92 bytes/sec 平均每秒传送数据:114385.92字节
Concurrency: 8.59 最高并发数 8.59
Successful transactions: 40 成功处理次数
Failed transactions: 0 失败处理次数


辅助工具:
增量压力测试:
为了方便增量压力测试,siege还包含了一些辅助工具:
bombardment (1)
是一个辅助工具:用于按照增量用户压力测试:
使用样例:
bombardment urlfile.txt 5 3 4 1
初始化URL列表:urlfile.txt
初始化为:5个用户
每次增加:3个用户
运行:4次
每个客户端之间的延迟为:1秒

输出成CSV格式:
siege2csv.pl (1)
siege2csv.pl将bombardment的输出变成CSV格式:
Time Data Transferred Response Time Transaction Rate Throughput Concurrency Code 200 (note that this is horribly broken.)
242 60.22 603064 0.02 4.02 10014.35 0.08
605 59.98 1507660 0.01 10.09 25136.05 0.12
938 59.98 2337496 0.02 15.64 38971.26 0.26
1157 60 2883244 0.04 19.28 48054.07 0.78



----------------------------------------------------4 http_load

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

程序非常小,解压后也不到100K 居家旅行 携带方便 呵呵

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

命令格式:http_load -p 并发访问进程数 -s 访问时间 需要访问的URL文件
例如:
引用
http_load -p 30 -s 60 urllist.txt

准 备URL文件:tst.list,文件格式是每行一个URL,URL最好超过50-100个测试效果比较好,另外,测试结果中主要的指标是 fetches/sec 这个选项,即服务器每秒能够响应的查询次数,用这个指标来衡量性能。似乎比 apache的ab准确率要高一些,也更有说服力一些。

官方的例子:
引用

% ./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 秒计算出来的




------------------5 Web Application Stress【附下载】
http://www.microsoft.com/downloads/details.aspx?FamilyID=e2c0585a-062a-439e-a67d-75a89aa36495&displaylang=en

说明:

1. 在“settings”的功能设置中,一个是Stress level (threads)这里是指定程序在后台用多少线程进行请求,也就是相当于模拟多少个客户机的连接,更加形象的就是说设置多少轰炸的线程数。一般填写 500~1000,因为这个线程数是根据本机的承受力来设置的,如果你对自己的机器配置有足够信心的话,那么设置的越高,轰炸的效果越好。

2.在“Test Run Time”中来指定一次压力测试需要持续的时间,分为天、小时、分、秒几个单位级别,你根据实际情况来设置吧!

使用:

在工具中点右键,选择Add命令,增加了一个新的测试项目:New script,对它进行设置,在主选项中的server中填写要测试的服务器的IP地址[192.168.200.100]。在下方选择测试的Web连接方式,这里的方式Verb选择 get,path选择要测试的Web页面路径[/info.php],

在“Settings”的功能设置中将Stress level (threads)线程数设置为1000。完毕后,点工具中的灰色三角按钮即可进行测试(如图4)。测试完毕,等待朋友把任务管理器以及连接查看的截图发过来!

攻 击开始后,朋友从任务管理器中可以看到CPU使用率已经达到100%,损耗率达到最大。在CMD窗口中使用命令netstat -an,可以看到我的IP地址在朋友服务器上的80端口进行了非常多的连接。而且它的Web网站已经打不开了,提示过多用户连接,达到了跟 D.O.S攻击一样的目的。

数据分析:
选择“View”菜单下的“Reports”命令,或单击工具栏上的 按钮,打开报告窗口,在左侧列表中展开相应的报告。

检查Socket Errors部分是否有任何的socket有关的错误(值不为0)。

Socket Errors
--------------------------------------------------------------------------------
Connect: 406
Send: 0
Recv: 306
Timeouts: 0

这里列出每种socket错误的解释:Connect——客户端不能与服务器取得连接的次数。如果这个值偏高,检查在客户端与服务器之间产生的任何潜在的错误。从每个客户端Ping服务器或telnet服务器的端口80验证你得到正确的回应;Send——客户端不能正确发送数据到服务器的次数。如果这个值偏高,检查服务器是否正确地工作着。在客户端打开一个浏览器然后手工点击站点页面验证站点正确地工作着;Recv——客户端不能正确从服务器接收数据的次数。如果这个值偏高,执行和Send错误相同的操作,还要检查一下如果你减低负载系数,错误是否跟着减少;Timeouts——超时的线程的数目,而且随后就关闭了。如果这个值偏高,在客户端打开一个浏览器,然后手工点击站点页面验证是否即使只有一个用户你的程序也会很慢。再做一个不同负载系数的压力测试,看看程序的潜在特征。

Result Codes
Code Description Count
================================================================================
200 OK 11058
NA HTTP result code not given 306
如果“socket”错误很低或为0,在左侧的报告列表中找到“Result Codes”部分。检查一下是否所有结果代码都是200,200表示所有请求都被服务器成功地返回。如果找到大于或等于400的结果,单击报告列表中的 “Page Data”节点,展开所有项目,查看每个脚本项在右边窗口页面数据的报告,找出出现错误的项目。


TAG:

 

评分:0

我来说两句

Open Toolbar