|
环境准备:
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
|
|