您的位置:首页 > 运维架构 > Linux

在linux中给你的应用做压力测试

2016-04-22 23:45 288 查看

在linux中给你的应用做压力测试

作者: 立地
邮箱: jarvin_g@126.com
QQ: 511363759

一.webbench

1.在Ubuntu中安装webbench —支持get,head等请求,但不支持post请求

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

2.测试demo

webbench -t 5 -c 2 http://google.com/   >2个并发用户共同请求5秒

3.测试结果分析

Benchmarking: GET http://google.com/ #GET方法请求谷歌


2 clients, running 5 sec. #2个用户,运行5秒




Speed=4296 pages/min, 38664 bytes/sec. #4296个页面每秒,38664 bytes每秒


Requests: 358 susceed, 0 failed. #358次请求成功,0次失败


二.ab

1.在Ubuntu中安装ab —支持 post ,get ,head 等方法

sudo apt-get install apache2-utils

2.测试demo

ab -n 500 -c 2  http://www.google.com/   >2个并发用户共同请求个数500个。

3.测试结果分析

Server Software: gws #服务器信息


Server Hostname: www.google.com #测试地址


Server Port: 80 #测试端口




Document Path: / #测试文档路径


Document Length: 390 bytes #测试文档大小




Concurrency Level: 2 #并发数量


Time taken for tests: 6.752 seconds #测试消耗时间


Complete requests: 500 #完成的请求数


Failed requests: 0 #失败的请求数


Non-2xx responses: 500 #HTTP响应数据的头信息中含有2XX以外的状态码的请求数


Total transferred: 566000 bytes #总传输数据大小


HTML transferred: 195000 bytes #总传输html数据大小


Requests per second: 74.05 [#/sec] (mean) #吞吐量,每秒处理平均请求数


Time per request: 27.007 [ms] (mean) #每个请求平均等待时间


Time per request: 13.504 [ms] (mean, across all concurrent requests) #服务器每个请求平均处理时间


Transfer rate: 81.86 [Kbytes/sec] received #平均每秒流量数




Connection Times (ms) #下面为时间花费的分布(连接、处理、等待、总数)


min mean[+/-sd] median max


Connect: 1 1 0.2 1 2


Processing: 22 26 7.6 25 150


Waiting: 22 26 7.6 25 150


Total: 23 27 7.6 26 151




###下面为每个请求花费时间的分布


Percentage of the requests served within a certain time (ms)


50% 26 #50%在26毫秒之内


66% 27 #66%在27毫秒之内


75% 27


80% 27


90% 28 #主要看这个参数,90%在28毫秒之内


95% 29


98% 36


99% 52


100% 151 (longest request)


如想在请求header加入数据,如下:

ab -H "Cookie: key=value;key2=value2" ...


4. 利用ab 进行post请求

ab -c 1 -n 100 -T 'application/json' -p data.json http://www.google.com/


测试结果就不贴上来了,多了一个明显的结果:

Total body sent: 15900 #body总的发送量
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: