首页 > 科技 > 如何控制Nginx并发连接数

如何控制Nginx并发连接数

模块说明

模块:nginx_http_limit_conn_module

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

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

Nginx并发连接数参数说明

limit_conn_zone参数:语法:limit_conn_zone key zone=name:size;上下文:http

用于设置共享内存区域,key可以是字符串,nginx自有变量或前两个组合,如$binary_remote_addr、$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.htmlThis 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).....doneServer Software:        nginxServer Hostname:        10.0.0.106Server Port:            80Document Path:          /index.htmlDocument 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)

本文来自投稿,不代表本人立场,如若转载,请注明出处:http://www.souzhinan.com/kj/263159.html