手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

LAMPX-AMPX测试篇

[日期:2012-12-06] 来源:51cto  作者:mos1989 [字体:大 中 小]

使用ab命令做简单的压力测试.

1、修改虚拟机hosts文件,使其解析域名linuxidc.example.com

  1. echo -e '192.168.88.131\tlinuxidc.example.com\n192.168.88.131\twww.example.com' >> /etc/hosts
  2. #追加完成后,直接使用ping linuxidc.example.com和www.example.com测试

2、简单的测试,譬如,200个用户,同时每个发10个请求到网页根目录的index.php文件

  1. ab -c 200 -n 2000 www.example.com/index.php

-c 有多少个用户同时发送请求, -n 总共发出的请求数
下面贴出笔者一个测试的结果作为范例注释:

 

  1. This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
  2. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  3. Licensed to The Apache Software Foundation, http://www.apache.org/
  4. #一些版本相关信息等
  5. Benchmarking linuxidc.example.com (be patient)
  6. Completed 200 requests
  7. Completed 400 requests
  8. Completed 600 requests
  9. Completed 800 requests
  10. Completed 1000 requests
  11. Completed 1200 requests
  12. Completed 1400 requests
  13. Completed 1600 requests
  14. Completed 1800 requests
  15. Completed 2000 requests
  16. Finished 2000 requests
  17. #进度...
  18. Server Software: Apache/2.4.3 #软件版本
  19. Server Hostname: linuxidc.example.com #测试主机
  20. Server Port: 80 #通过80端口
  21. Document Path: /wp-login.php #测试页面wordpress登陆页面
  22. Document Length: 242 bytes #测试页面大小
  23. Concurrency Level: 200 #测试的并发请求数
  24. Time taken for tests: 18.055 seconds #测试总耗时
  25. Complete requests: 2000 #全部请求书
  26. Failed requests: 276 #失败的请求
  27. (Connect: 0, Receive: 0, Length: 276, Exceptions: 0)
  28. Write errors: 0
  29. Non-2xx responses: 1724
  30. Total transferred: 1771164 bytes #一共传输的字节
  31. HTML transferred: 999844 bytes #生成的html的内容传输总量
  32. Requests per second: 110.77 [#/sec] (mean) #大概每秒能完成几个
  33. Time per request: 1805.550 [ms] (mean) #每个请求大概耗时
  34. Time per request: 9.028 [ms] (mean, across all concurrent requests) #相对于所有的并发请求,平均每个用时多久
  35. Transfer rate: 95.80 [Kbytes/sec] received #传输速率...介个真心不高,估计是用的虚拟网卡缘故
  36. Connection Times (ms) #连接时间
  37. min mean[+/-sd] median max
  38. Connect: 0 7 22.6 0 140 #连接
  39. Processing: 23 1667 2587.2 704 16935 #处理
  40. Waiting: 0 1665 2587.3 704 16935 #等待
  41. Total: 24 1674 2593.1 720 16968
  42. Percentage of the requests served within a certain time (ms)
  43. 50% 720
  44. 66% 1198
  45. 75% 1562
  46. 80% 2107
  47. 90% 5423
  48. 95% 7555
  49. 98% 9908
  50. 99% 12855
  51. 100% 16968 (longest request)
  52. #某个时间段的平均处理速率.


Ps:
测试时,尽量使用局域网测试,上面的结果,笔者的本地虚拟网卡,的传输速度太慢了,这估计是由于vmware虚拟网卡自身的问题,这已经严重影响了测试的有效性.

测试时,可以开多个控制台,使用vmstat 1和top,以及网页的status进行观察系统满载时的各种详细参数.

ab测试时,尽量使用多个页面,多次测试,去平均值为最好,若测试的精细,可对XCache开启和关闭的效果分别测试,以及apache的mpm的几个工作模型做详细修改测试,以及apache内各种配置的关闭和开启后的效果测,方式都是一样(笔者很多都正在测试).

linux
相关资讯       lamp  LAMPX 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意��容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款