利用 apache 自带的 ab 对 web 进行压力测试

sara , 创建:2014-03-11 18:48, 更新:2014-03-12 21:47 标签: apache ab


一、安装 ab 是 Apache 自带的压力测试工具,全称是 ApacheBench 1. 安装 apache

yum install httpd
2.不安装 apache 只安装 ab 工具
yum install httpd-tools
二、测试命令 模拟 1 个并发用户,对一个页面发送 2000 个请求
/usr/bin/ab -c 1 -n 2000 http://192.168.1.88/
其中-n代表请求数,-c代表并发数 三、结果分析
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.1.88 (be patient)


Server Software:        nginx/1.0.15    #Web服务器引擎
Server Hostname:        192.168.1.88    #服务器地址
Server Port:            80              #服务器端口

Document Path:          /               #请求的文件路径
Document Length:        131 bytes       #文件大小

Concurrency Level:      1               #并发次数
Time taken for tests:   2.740 seconds   #测试所需时间
Complete requests:      2000            #成功请求次数
Failed requests:        0               #失败请求次数
Write errors:           0               #写入错误
Total transferred:      684000 bytes    #测试过程传输字节数,包含http的头信息等
HTML transferred:       262000 bytes    #HTML内容传输字节数
Requests per second:    729.94 [#/sec] (mean) #每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量 
Time per request:       1.370 [ms] (mean) #平均响应时间(用户平均请求等待时间)
Time per request:       1.370 [ms] (mean, across all concurrent requests) #平均并发请求时间(服务器平均处理时间,也就是服务器吞吐量的倒数 )
Transfer rate:          243.79 [Kbytes/sec] received #平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

Connection Times (ms) #响应时间小、中、大值
              min  mean[+/-sd] median   max
Connect:        0    1  22.3      0     999
Processing:     0    1   0.7      0      18
Waiting:        0    1   0.7      0      18
Total:          1    1  22.4      1    1000
WARNING: The median and mean for the processing time are not within a normal deviation
        These results are probably not that reliable.
WARNING: The median and mean for the waiting time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      1
  99%      2
 100%   1000 (longest request)
参考: http://www.nginx.cn/110.html#more-110 http://www.ha97.com/4617.html


发表评论