NGINX: Limit the number of connections to an upstream server

10,246

For the max_conns parameter docs states that:

Since version 1.5.9 and prior to version 1.11.5, this parameter was available as part of our commercial subscription.

So, now it is available in the free public version.

Share:
10,246
Admin
Author by

Admin

Updated on June 25, 2022

Comments

  • Admin
    Admin almost 2 years

    I am using NGINX as a reverse proxy to an upstream server.

    Is there any way that I can limit the number of simultaneous connections NGINX establishes to the upstream server?

    The desired behaviour is:

    • NGINX keeps a maximum of n connections to the upstream
    • If clients make (n + m) connections then m connections should be queued and submitted to the upstream server as soon as an established connection becomes free.

    The NGINX documentation alludes to a couple of parameters in the module ngx_http_upstream_module namely max_conns and queue. The problem is that these parameters are only available in the commercial version of NGINX.

    Is there any other way of achieving this behaviour without resorting to the commercial version of NGINX?

  • sherpya
    sherpya over 4 years
    unfortunately exceding connections are dropped with 502
  • Daniel Dickison
    Daniel Dickison over 3 years
    Yeah, unfortunately queue is still only available in the commercial versions: nginx.org/en/docs/http/ngx_http_upstream_module.html#queue