测试工具AB的使用

一、什么是ab

ab是apache自带的压力测试工具。ab不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试。

二、安装

yum -y install httpd-tools
apt install apache2-utils

三、ab的使用

  • 源码
  • POST文件
[root@localhost mau]# vim postdata.txt 
name=chang&passwd=1111
  • 压测命令
[root@localhost mau]# ab -c 2 -n 2 -p /tmp/mau/postdata.txt -H "X-FORWARDED-FOR:172.16.1.134" -T application/x-www-form-urlencoded http://127.0.0.1:6666/test.php
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).....done


Server Software:        BDWEB/1.9.9
Server Hostname:        127.0.0.1
Server Port:            6666

Document Path:          /test.php
Document Length:        13 bytes

Concurrency Level:      2
Time taken for tests:   0.001 seconds
Complete requests:      2
Failed requests:        0
Write errors:           0
Total transferred:      356 bytes
Total body sent:        468
HTML transferred:       26 bytes
Requests per second:    1806.68 [#/sec] (mean)
Time per request:       1.107 [ms] (mean)
Time per request:       0.553 [ms] (mean, across all concurrent requests)
Transfer rate:          314.05 [Kbytes/sec] received
                        412.86 kb/s sent
                        726.91 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      1       1
Processing:     0    1   0.4      1       1
Waiting:        0    0   0.3      0       0
Total:          1    1   0.1      1       1
ERROR: The median and mean for the initial connection time are more than twice the standard
       deviation apart. These results are NOT 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%      1
 100%      1 (longest request)
  • 测试结果
172.16.1.134
array (
  'name' => 'chang',
  'passwd' => '22222
',
)
172.16.1.134

你可能感兴趣的:(测试工具AB的使用)