4

trying to use NGINX as reverse proxy, and would like to have constant number of open connections to backend (upstream) open at all times.

Is this possible with nginx (maybe haproxy..?) ??

running on ubuntu if it makes any difference

Arieh Leviav
  • 322
  • 3
  • 9

2 Answers2

2

Something like that can be done easily with haproxy. The end result will be that there are no more than N concurrent connections to a backend server + open connections are shared between requests coming from different clients.

backend app
  http-reuse safe
  server server1 127.0.0.1:8080 maxconn 32
  server server2 127.0.0.2:8080 maxconn 32

The example shows 2 servers, haproxy will not open more than 32 connection to each server, and each connection can be shared between several clients whenever that can be done safely.

Tair
  • 3,779
  • 2
  • 20
  • 33
2

Community edition of Nginx does not provide such functionality.

A commercial version of Nginx provides. There is max_conns parameter in upstream's servers:

upstream my_backend {
    server 127.0.0.1:11211 max_conns=32;
    server 10.0.0.2:11211 max_conns=32;
}

The documentation is here

Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54