一、安装Apache

yum install httpd


二、使用ab命令 (注意,最后面一定要加斜杠 ‘/’)

ab -n 100 -c 100 http://www.xxx.gd/

“-n”表示:每次请求数,默认不能超过1024个,否则需要修改系统进程限制。
“-c”表示:1个请求的并发连接数,默认最大不能超过5000


三、查看结果

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 www.kwx.gd (be patient)
Finished 130 requests


Server Software:        nginx/1.0.10 #Web服务器引擎Server Hostname:        www.kwx.gd   #服务器地址Server Port:            80           #服务器端口Document Path:          /            #请求的文件路径Document Length:        20718 bytes  #文件大小Concurrency Level:      1020         #并发次数Time taken for tests:   20.6751 seconds #测试所需时间Complete requests:      130          #成功请求次数Failed requests:        0            #失败请求次数Write errors:           0            #写入错误Total transferred:      3041510 bytes #测试过程传输字节数HTML transferred:       2957081 bytes #HTML内容传输字节数Requests per second:    6.50 [#/sec] (mean) #平均返回数据时间Time per request:       156976.039 [ms] (mean) #平均响应时间Time per request:       153.898 [ms] (mean, across all concurrent requests)
#平均并发请求时间
Transfer rate:          148.45 [Kbytes/sec] received #平均传输速率Connection Times (ms)   #响应时间小、中、大值
              min  mean[+/-sd] median   max
Connect:      322  346  18.0    338     401
Processing:  1344 8898 4081.5   9795   19341
Waiting:      669 7629 3782.7   8802   18617
Total:       1682 9245 4087.6  10148   19684

Percentage of the requests served within a certain time (ms)
  50%  10148
  66%  11054
  75%  11567
  80%  12797
  90%  14636
  95%  15551
  98%  16834
  99%  18119
 100%  19684 (longest request)
#以上为所有请求的平均速度,如在测试过程中进度到50%时平均响应时间为10148ms,到66%时
平均响应时间为11054ms。