Nginx学习(九) 使用ab压力测试Nginx

Xylona ·
更新时间:2024-11-13
· 671 次阅读

测试环境:VMWARE创建的虚拟机
2个CPU 3.7G内存
在这里插入图片描述

1、安装httpd

yum install httpd

2、模拟1000个用户50000次请求Nginx首页

cd /usr/bin ./ab -c 1000 -n 50000 localhost:88/index.html

结果:

Server Software: nginx/1.17.8 Server Hostname: localhost Server Port: 88 Document Path: /index.html Document Length: 612 bytes Concurrency Level: 1000 Time taken for tests: 4.623 seconds Complete requests: 50000 Failed requests: 0 Write errors: 0 Total transferred: 42250000 bytes HTML transferred: 30600000 bytes Requests per second: 10814.71 [#/sec] (mean) Time per request: 92.467 [ms] (mean) Time per request: 0.092 [ms] (mean, across all concurrent requests) Transfer rate: 8924.25 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 40 81.9 28 1060 Processing: 13 50 22.0 42 136 Waiting: 4 39 19.0 33 131 Total: 43 90 87.9 68 1159 Percentage of the requests served within a certain time (ms) 50% 68 66% 81 75% 97 80% 114 90% 138 95% 158 98% 173 99% 178 100% 1159 (longest request)

3、安装nginx统计模块with-http_stub_status_module
进入nginx解压的目录

./configure --prefix=/usr/local/nginx --with-http_stub_status_module make && make install

4、开启统计模块

gedit /usr/local/nginx/conf/nginx.conf

添加

location /status { stub_status on; access_log off; allow 192.168.1.72; deny all; } /usr/local/nginx/sbin/nginx -s reload

访问http://192.168.1.72:88/status
在这里插入图片描述
5、再次使用ab压测
重复第2步
压测过程中可以查看nginx统计
在这里插入图片描述


作者:码农-文若书生



ab Nginx

需要 登录 后方可回复, 如果你还没有账号请 注册新账号