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

在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.测试结果分析

  1. Benchmarking: GET http://google.com/ #GET方法请求谷歌
  2. 2 clients, running 5 sec. #2个用户,运行5秒
  3. Speed=4296 pages/min, 38664 bytes/sec. #4296个页面每秒,38664 bytes每秒
  4. 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.测试结果分析

  1. Server Software: gws #服务器信息
  2. Server Hostname: www.google.com #测试地址
  3. Server Port: 80 #测试端口
  4. Document Path: / #测试文档路径
  5. Document Length: 390 bytes #测试文档大小
  6. Concurrency Level: 2 #并发数量
  7. Time taken for tests: 6.752 seconds #测试消耗时间
  8. Complete requests: 500 #完成的请求数
  9. Failed requests: 0 #失败的请求数
  10. Non-2xx responses: 500 HTTP响应数据的头信息中含有2XX以外的状态码的请求数
  11. Total transferred: 566000 bytes #总传输数据大小
  12. HTML transferred: 195000 bytes #总传输html数据大小
  13. Requests per second: 74.05 [#/sec] (mean) #吞吐量,每秒处理平均请求数
  14. Time per request: 27.007 [ms] (mean) #每个请求平均等待时间
  15. Time per request: 13.504 [ms] (mean, across all concurrent requests) #服务器每个请求平均处理时间
  16. Transfer rate: 81.86 [Kbytes/sec] received #平均每秒流量数
  17. Connection Times (ms) #下面为时间花费的分布(连接、处理、等待、总数)
  18. min mean[+/-sd] median max
  19. Connect: 1 1 0.2 1 2
  20. Processing: 22 26 7.6 25 150
  21. Waiting: 22 26 7.6 25 150
  22. Total: 23 27 7.6 26 151
  23. ###下面为每个请求花费时间的分布
  24. Percentage of the requests served within a certain time (ms)
  25. 50% 26 50%在26毫秒之内
  26. 66% 27 66%在27毫秒之内
  27. 75% 27
  28. 80% 27
  29. 90% 28 #主要看这个参数,90%在28毫秒之内
  30. 95% 29
  31. 98% 36
  32. 99% 52
  33. 100% 151 (longest request)

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

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

4. 利用ab 进行post请求

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

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

  1. Total body sent: 15900 body总的发送量
posted @ 2016-04-22 23:45  ♂立地←  阅读(754)  评论(0编辑  收藏  举报