apache benchmark(ab)是一种常见的压测工具,不仅可以对apache进行压测,也可以对nginx,tomcat,IIS等进行压测

安装

如果安装了apache,那么ab已经自带了,不需要再额外安装,如果没有安装apache,可以通过以下方式安装

# ubuntu
sudo apt-get install apache2-util # centos
yum -y install httpd-tools

压测

在压测前,需要关注几个选项,通过ab --help查看

-n  requests       要执行的请求次数
-c concurrency 并发数量
-s timeout 响应时间

#### 执行

执行以下代码进行压测

ab -n 1000 -c 100 -s 1 http://127.0.0.1:1080/index
# 一共1000个请求,并发100,超时时间为1s,后面为测试的url

测试结果

apr_pollset_poll: The timeout specified has expired (70007)
Total of 997 requests completed

显示有997个请求完成了,而且报错了,说明有请求超过1s,所以把超时时间去掉重新测试

ab -n 1000 -c 100 http://127.0.0.1:1080/index

结果

Server Software:        nginx/x.x.x
Server Hostname: www.my.com
Server Port: 80 Document Path: /
Document Length: 2368 bytes Concurrency Level: 100
Time taken for tests: 30.914 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2527000 bytes
HTML transferred: 2368000 bytes
Requests per second: 32.35 [#/sec] (mean)
Time per request: 3091.393 [ms] (mean)
Time per request: 30.914 [ms] (mean, across all concurrent requests)
Transfer rate: 79.83 [Kbytes/sec] received Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 174 381.6 0 2006
Processing: 1 2391 6166.6 205 25853
Waiting: 1 2080 5941.6 205 25853
Total: 2 2565 6143.6 406 26609 Percentage of the requests served within a certain time (ms)
50% 406
66% 1004
75% 1413
80% 1616
90% 6448
95% 25760
98% 25824
99% 25855
100% 26609 (longest request)

这里我们需要关注以下几个数据

1)Failed requests:失败的请求

2)Requests per second:也就是常说的QPS, 每秒查询率,这是一个平均值

3)Time per request:完成一个请求所花费的时间

4)Transfer rate: 网络传输速度。 对于大文件的请求测试,这个值很容易成为系统瓶颈所在 要确定该值是不是瓶颈,需要了解客户端和被测服务器之间的网络情况,包括网络带宽和网卡速度等信息。

最新文章

  1. 修改Linux时间一般涉及到3个命令: date, clock, hwclock
  2. QTP之对测试用例的自动化过程的分解
  3. SqlServer获取两个日期时间差
  4. Mysql 如何删除数据表中的重复数据!
  5. 2817 Tangent的愤怒 - Wikioi
  6. 采购件不允许挂BOM
  7. C学习之指针强化
  8. Python内置函数(41)——id
  9. HDU 1051(处理木棍 贪心)
  10. HDFS基础配置
  11. 三角形(hdu1249)递推
  12. 【精】搭建redis cluster集群,JedisCluster带密码访问【解决当中各种坑】!
  13. vue操作的填坑之旅
  14. spring-IOC容器(一)
  15. vim粘贴乱码的原因
  16. linux命令-每天一点进步
  17. Spring 如何读取properties文件内容
  18. 转:SQL Server附加数据库提示“版本为661,无法打开,支持655版本……”
  19. Python:正则表达式—— re 模块
  20. ios7中的edgesForExtendedLayout

热门文章

  1. 《MIT 6.828 Homework 1: boot xv6》解题报告
  2. [CF997C]Sky Full of Stars_二项式反演_等比数列_容斥原理
  3. #【Python】【基础知识】【模块】【Python的常用模块】
  4. 最新精仿Chinaz中国站长网整站源码带全部数据带采集功能
  5. WPF入门(3)——命令
  6. 【转载】STM32 IAP 在线升级详解
  7. volatile 关键字(修饰变量)
  8. MVC和WebApi中设置Area中的页为首页
  9. winfrom_关于打印小票
  10. .net core 根据数据库生成实体类