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

测试环境: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统计
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值