Nginx限制并发连接数

2023-11-22 0 980

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。

模块说明

模块:nginx_http_limit_conn_module

模块作用:限制每个key值的连接数,特别是单个IP连接数。

不是所有的连接数都会被计算,一个符合要求的连接是整个请求已经被读取的连接。

Nginx并发连接数参数说明

limit_conn_zone参数:

语法:limit_conn_zone key zone=name:size;

上下文:http

用于设置共享内存区域,key可以是字符串,nginx自有变量或前两个组合,如server_name。name为内存区域的名称,size为内存区域的大小。

limit_conn参数:

语法:limit_conn zone number;

上下文:http、server、location

在客户端使用Apache的ab测试工具进行测试

linux下安装ab测试工具

[root@localhost ~]# yum -y install httpd-tools

[root@localhost ~]# ab -V

使用ab 进行测试

ab -c 10 -n 100 http://10.0.0.106/index.html

##语法:-c并发数,-n请求数,nginx服务器IP

[root@localhost ~]# ab -c 10 -n 100 http://10.0.0.106/index.html

This is ApacheBench, Version 2.3 $Revision: 1430300 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.0.0.106 (be patient).....done

Server Software:        nginx

Server Hostname:        10.0.0.106

Server Port:            80

Document Path:          /index.html

Document Length:        162 bytes

。。。。省略若干

Percentage of the requests served within a certain time (ms)

 50%      1

 66%      1

 75%      1

 80%      1

 90%      2

 95%      3

 98%      3

 99%      3

100%      3 (longest request)

如何控制Nginx并发连接数如何控制Nginx并发连接数

本文来源:www.lxlinux.net/8054.html,若引用不当,请联系修改。

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 4975 +

    运行天数

你的前景,远超我们想象