AB(Apache Benchmark)测试工具使用

安装Apache Benchmark

Install apr-util(need to run ab):

yum install apr-util

Install yum-utils:

yum install yum-utils

Download httpd an extract ab:

mkdir ~/httpd
cd ~/httpd
yumdownloader httpd
rpm2cpio httpd-2.2.3-43.el5.centos.3.i386.rpm | cpio -idmv
mv usr/bin/ab /usr/bin/ab
cd ~
rm -rf ~/httpd

常用命令

  • -c    并发数
  • -n    总请求次数
  • -t     等待最大秒数
  • -s    每个响应最大超时时间

官方文档

执行结果

$ ab -c 10 -n 10000 http://localhost:8080/ 
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   0.290 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      1160000 bytes
HTML transferred:       0 bytes
Requests per second:    34461.01 [#/sec] (mean)
Time per request:       0.290 [ms] (mean)
Time per request:       0.029 [ms] (mean, across all concurrent requests)
Transfer rate:          3903.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       2
Processing:     0    0   0.2      0       5
Waiting:        0    0   0.2      0       5
Total:          0    0   0.2      0       5

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      1
  98%      1
  99%      1
 100%      5 (longest request)

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注