Limit_conn is not limiting the number of connections in my use case

Hello,

I have a hard time understanding limit_conn

My NGINX has the configuration below. I would expect to see 16
connections
on the backend server 192.168.10.131 defined in the “dynamic” directive.

Yet I see ~50-60 connections.

QPS: 3056
Active connections: 58
QPS: 3064
Active connections: 54
QPS: 3063
Active connections: 59

Please note the QPS (Query Per Second) limiting works well.

I would greatly appreciate any tip as to what is going on with my use of
the
limit_conn.

Thank you.

upstream locallayer {
server 127.0.0.1:7999;
keepalive 32;
}

server {
listen 8002;
proxy_intercept_errors on;

location / {
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_pass http://locallayer;
}
error_page 302 400 403 404 408 500 502 503 504 = /empty;
location /empty {
    return 204;
}

}

upstream dynamic {
least_conn;
server 192.168.10.131:9990;
keepalive 32;
}

limit_conn_zone $binary_remote_addr zone=peripconn:100m;
limit_conn_zone $server_name zone=perserver:10m;
limit_req_zone $binary_remote_addr zone=peripreq:1000m rate=3000r/s;

server {
listen 7999;
server_name local.com;
proxy_intercept_errors on;
location / {
allow 127.0.0.1;
deny all;
limit_conn peripconn 32;
limit_conn perserver 32;
limit_req zone=peripreq burst=100 nodelay;
limit_conn_status 503;
limit_req_status 503;
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_connect_timeout 10ms;
proxy_send_timeout 10ms;
proxy_read_timeout 60ms;
proxy_pass http://dynamic;
}
error_page 302 400 403 404 408 500 502 503 504 = /empty;
location /empty {
return 204;
}
}

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,267688,267688#msg-267688

On Saturday 18 June 2016 11:49:16 matt_l wrote:

Active connections: 58
QPS: 3064
Active connections: 54
QPS: 3063
Active connections: 59

Please note the QPS (Query Per Second) limiting works well.

I would greatly appreciate any tip as to what is going on with my use of the
limit_conn.
[…]

The limit_conn module doesn’t limit number of connections to upstream.
It’s all about client connections.

Since you have configured “keepalive 32” each worker process can keep
open
up to 32 connections to your backend even without client requests.

wbr, Valentin V. Bartenev

try this one plz

https://github.com/cfsego/nginx-limit-upstream

On Sun, Jun 19, 2016 at 6:41 AM, Valentin V. Bartenev [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs