找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 8732|回复: 0

AB高性能压力测试

[复制链接]

304

主题

42

回帖

1348

积分

管理员

积分
1348
发表于 2021-4-16 18:10:53 | 显示全部楼层 |阅读模式
环境准备:
1.LNMP编译安装+默认配置
2.PHP论坛项目discuz
3.开启nginx status
4.开启php-fpm status

ab命令路径:
1.linux
yum -y install httpd-tools
ab

2.win cmder
ab

ab命令参数:
1.-n        请求数
2.-c          并发数
3.-t         多长时间

命令实例:
ab -n 10 -c 1  http://192.168.2.1/index.php
ab -n 10 -c 10  http://192.168.2.1/index.php

结果分析:
1.请求进度
Benchmarking 192.168.2.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

2.服务器环境
Server Software:        Nginx/1.17.5
Server Hostname:        192.168.2.1
Server Port:            80

3.访问文件
Document Path:          /index.php
Document Length:        12195 bytes

4.并发请求结果
Concurrency Level:      1000
Time taken for tests:   19.850 seconds
Complete requests:      1000
Failed requests:        865
   (Connect: 0, Receive: 0, Length: 865, Exceptions: 0)
Total transferred:      12996236 bytes

Requests per second:    50.38 [#/sec] (mean)
Time per request:       19850.287 [ms] (mean)
Time per request:       19.850 [ms] (mean, across all concurrent requests)
Transfer rate:          639.37 [Kbytes/sec] received

6.请求服务时间
Percentage of the requests served within a certain time (ms)
  50%  12397
  66%  15523
  75%  15693
  80%  15825
  90%  18858
  95%  18886
  98%  18897
  99%  18906
100%  18909 (longest request)

7.Failed requests解释
Failed requests:  865 (Connect: 0, Receive: 0, Length: 865, Exceptions: 0)
#这种长度反馈不是测试错误,是正常情况,跟第一次请求得到的数据长度不一致,静态html网站是一致的,但动态PHP网站一般不一致

Linux服务器内存快速回收:
vi mem.sh
#!/bin/bash

sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|外汇论坛 ( 粤ICP备16021788号 )

GMT+8, 2024-12-22 21:09 , Processed in 0.075528 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表