红联Linux门户
Linux帮助

Ubuntu下Siege压力测试

发布时间:2014-08-08 21:42:12来源:linux网站作者:zinss26914

定义

siege(英文是围攻)是一个压力测试和评测工具,设计用于web开发这评估应用在压力下的承受能力;可以配置针对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的响应时间,并在一定数量的并发访问下重复进行


安装

Ubuntu下安装软件尽量通过apt-get方式安装,避免自己搞依赖关系

sudo apt-cache search siege


会显示:

siege - HTTP regression testing and benchmarking utility


安装:

sudo apt-get install siege


测试

测试代码

#!/bin/bash
user_agent="Siege wangzhengyi 1.0"
siege_rc="siege.rc"
concurrent=150
repet=200
siege_single_urls="singleurl.txt"
siege_prefix_urls="prefixurl.txt"
 
siege -R $siege_rc -c $concurrent -r $repet -i -b -A "$user_agent" -f $siege_single_urls


参数详解

-R: 指定用特定的siege配置文件来运行
-c: 模拟有N个用户在并发访问(ps:如果WEB服务器为apache的话,请不要将并发连接数设置超过200)
-r:  重复测试运行N次
-i:  随机访问-f指定的url.txt中的url列表项,以此模拟真实的访问情况(随机性)
-b: 进行压力测试,不进行延时
-A: 指定访问的user-agent
-f: 任务的URL列表


结果说明

** SIEGE 2.68
** Preparing 150 concurrent users for battle.
The server is now under siege...
done.
Transactions:              29777 hits  //完成了29777次攻击
Availability:              99.26 %  //99.26%的成功率
Elapsed time:            268.34 secs  //总共使用时间
Data transferred:          2.27 MB  //总共数据传输 2.27MB
Response time:              1.34 secs  //响应时间,显示网络连接速度
Transaction rate:        110.97 trans/sec  //平均每秒完成110.97次处理
Throughput:            0.01 MB/sec  //平均每秒传输数据0.01MB
Concurrency:              148.38  //实际最高并发连接数143.38
Successful transactions:      29777  //成功处理次数29777
Failed transactions:            223  //失败处理次数223
Longest transaction:            3.14  //每次传输的最长时间
Shortest transaction:          0.00  //每次传输的最短时间