Welcome! Log In Create A New Profile

Advanced

“max_conns” in upstream is not working what I've expected;

August 21, 2018 10:58PM
Hello Super Heroes.

I want to limit connections in a service. So I used max_conns directive in upstream.

But it allows twice connections as many as I've set.

So, I suspected myself. Maybe… Am I used the direction in wrong way.

And I found some descriptions about “max_conns” exception rules.

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#server

----
If idle keepalive connections, multiple workers, and the shared memory are enabled, the total number of active and idle connections to the proxied server may exceed the max_conns value.
----

And I’ve tried change configuration of “keepalive”, “worker numbers” and “shared memory”. But it still the same. It allowed twice connections as many as I expected.


My config file is blow.

#
# max_conns Test Server
#

proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60s use_temp_path=off;

proxy_cache_key "$scheme$request_method$host$request_uri";

upstream t10 {
zone t1_z 1M;
server localhost:8080 max_conns=5 max_fails=0 fail_timeout=1s;
}

server {
listen 8000 ;
location /test/1 {
proxy_pass http://t10; # it takes 1 seconds
}
}

And I run a shell script blow.

for v in {1..40}
do
curl 'localhost:8000/test/1' -i -l >> 30_2.log &
sleep 0.01
done

----

The url ‘localhost:8080/test/1’ takes 1 seconds.

I expected 5 succeed and 35 fail. But it always 10 succeed, 30 failed.
Subject Author Posted

“max_conns” in upstream is not working what I've expected;

jinsam.kim August 21, 2018 10:58PM

Re: “max_conns” in upstream is not working what I've expected;

jinsam.kim August 22, 2018 09:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 131
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready