AB-apache bench
不限于apache服务器,只是模拟访问的工具而已
安装yum install httpd-tools

  1. 使用get请求方式进行压侧:

命令举例:ab -c 100 -n 1000 http://xxxx/index.php/user/login
(记得用完整路径, -c 并发数, -n 总共的请求数, 默认使用get请求方式)

  1. 使用post请求方式进行压侧:

在当前目录下创建一个文件post.txt

编辑文件post.txt写入

cid=4&status=1

相当于post传递cid,status参数,输入命令:

ab -c 10 -n 100 -p 'post.txt' -T 'application/x-www-form-urlencoded' 'http://test.api.com/ttk/auth/info/'

运行结果说明:

Server Software:        Apache/2.4.18         服务器软件版本
Server Hostname:        www.06a.com        请求的URL
Server Port:            80                                 请求的端口号

Document Path:          /                                请求的服务器的路径
Document Length:        19590 bytes            页面长度   单位是字节

Concurrency Level:      200                          并发数
Time taken for tests:   124.509 seconds      一共使用了124s      
Complete requests:      1000                        请求的次数
Failed requests:        9                                   失败的请求     
   (Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
Total transferred:      19669661 bytes          总共传输的字节数  http头信息
HTML transferred:       19472463 bytes       实际页面传递的字节数
Requests per second:    8.03 [#/sec] (mean) 每秒多少个请求
Time per request:       24901.805 [ms] (mean)  平均每个用户等待多长时间
Time per request:       124.509 [ms] (mean, across all concurrent requests)   服务器平均用多长时间处理
Transfer rate:          154.28 [Kbytes/sec] received  每秒获取多少数据

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.0      0      62
Processing:  4679 17276 7877.7  15587   64050
Waiting:     4675 17273 7877.1  15586   64050
Total:       4679 17277 7877.8  15588   64051

Percentage of the requests served within a certain time (ms)
  50%  15588    50%的用户的请求15588ms内返回
  66%  21097
  75%  24071
  80%  25294
  90%  27939
  95%  29550
  98%  32122
  99%  34885
 100%  64051 (longest request)

标签: AB, 压力测试, 负载测试

添加新评论