<div dir="ltr"><br clear="all"><div><div><div><div><div>Hello Nginx Users,<br><br></div>I am running
nginx as a TCP load balancer (streams module). I am trying to find a way to redistribute
client TCP connections to upstream servers, specifically, rebalance the
load on the upstream servers (on some event) w/o having to restart nignx. Clients use
persistent TCP connections.<br><br></div>The scenario is as follows<br></div><br>Application
protocol - There is an application level ack for unit-of-work, so unclean connection termination is ok.<br><br>Persistent
TCP connections - Client opens persistent TCP connections, focus is on near real-time delivery of small amount of data. Connection stays open for days.<br></div></div><div><br>Maintenance/Downtime
- When one of the upstream servers is shutdown for maintenance, all
it's client connections break, clients reconnect and switch to one of
the remaining active upstream servers. When the upstream is brought back
up post maintenance, the load isnt redistributed. ie., existing
connections (since they are persistent) remain with other servers. Only
new connections can go to the new server. This is more pronounced in 2
upstream server setup...where all connections switch between
servers....kind of like thundering herd problem.<br><br></div><div>I
would like to have the ability to terminate some/all client connections
explicitly and have them reconnect back. I understand that with nginx
maintaining 2 connections for every client, there might not be a 'clean'
time to close the connection, but since there is an application ack on
top...an unclean termination is acceptable. I currently have to restart
nginx to rebalance the upstreams which effectively is the same. <br><br>Restarting
all upstream servers and synchronizing their startup is non-trivial. So
is signalling all clients(1000s) to close and reconnect. I
can achieve this partially by disabling keepalive on nginx listen port
(so_keepalive=off) and then having least_conn as the load-balancer
method on my upstream. However, this is not desirable in steady state
(see persistent TCP connections above), and even though connections get
evenly distributed...the load might no be...as idle and busy clients
will end up with different upstreams.<br></div><div><br></div><div>Nginx
plus features like, "On the fly configuration" upstream_conf allows
one to change the upstream configuration, but it doesnt affect existing
connections, even if a server is marked as down. "Draining of sessions"
is only applicable to http requests and not to TCP connections.<br><br></div><div>Did anyone else face such a problem? How did you resolve it? Any pointers will be much appreciated.<br></div><div><br></div><div>thanks,<br></div><div>balaji<br></div><div><br></div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Balaji Viswanathan<br>Bangalore<br>India</div></div></div>
</div>