最近研究APACHE的优化问题,发现 ab 这东东还是不错的,可为衡量APACHE性能提供一些有价值的参考依据。

./ab -n 50000 -c 1000  http://localhost/bbs/index.php

//这个表示1000个用户 发送 50000请求 index.php文件的动作,服务器的处理情况如下: 


This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking  localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Finished 50000 requests
 
Server Software:        Apache/2.2.3                     //平台apache 版本 2.2.3
Server Hostname:        localhost                   //服务器主机名
Server Port: 80                                     //服务器端口
Document Path: /bbs/index.php                 //测试的页面文档
Document Length: 303 bytes                  //文档大小
Concurrency Level: 1000                        //并发数
Time taken for tests:   37.468807 seconds                    //整个测试持续的时间
Complete requests:      50000              //完成的请求总数
Failed requests: 0                                 //失败的请求数量
Write errors: 0                              //读写错误的请求数量
Non-2xx responses:      50092                    //正常响应请求的总数
Total transferred:      26198116 bytes                 //整个场景中的网络传输量
HTML transferred:       15177876 bytes                //整个场景中的HTML内容传输量
Requests per second:    1334.44 [#/sec] (mean)
//关键指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值
Time per request:       749.376 [ms] (mean)
//大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值
Time per request:       0.749 [ms] (mean, across all concurrent requests)
//每个请求实际运行时间的平均值
Transfer rate:          682.81 [Kbytes/sec] received
//平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题Connection Times (ms)
                         min  mean[+/-sd] median   max
Connect:           0    14 168.2                 3        3015
Processing:     0    191 1794.0             35      37423
Waiting:           0    178 1795.1             15       37421
Total:               9    206 1804.8            37         37461
//网络上消耗的时间的分解
 
Percentage of the requests served within a certain time (ms)
  50%     37
  66%     43
  75%     46
  80%     48
  90%     53
  95%     58
  98%    263
  99%   3000
 100%  37461 (longest request)
//整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于37 毫秒,66% 的用户响应时间小于43 毫秒,最大的响应时间小于37461 毫秒 。

备注:APACHE官网上关于AB的介绍:http://httpd.apache.org/docs/2.0/programs/ab.html