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