美图齐众专注资阳网站设计 资阳网站制作 资阳网站建设
资阳网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Nginx限制并发连接数

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并发连接数


网站名称:Nginx限制并发连接数
当前网址:http://www.zsjierui.cn/article/djijogh.html