[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nginx
Subject:    =?UTF-8?Q?=E2=80=9Cmax_conns=E2=80=9D_in_upstream_is_not_working_what_I=27?= =?UTF-8?Q?ve_expected=3
From:       "jinsam.kim" <nginx-forum () forum ! nginx ! org>
Date:       2018-08-22 2:58:15
Message-ID: 02289aa0fa5e0c22e9562245273b68bd.NginxMailingListEnglish () forum ! nginx ! org
[Download RAW message or body]

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.

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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic