Connection draining

Hi, I could not find a detailed description of what is happening to active connections when a node is removed from an upstream. I only found in the Load Balancing reference that “no in progress requests will be dropped”. Is there any configurable timeout? What if there are idle connections? Can I setup a timeout for idle connections?



Kong (or OpenResty, for that is) has no control over the upstream connections opened by NGINX to your remote backends. When Targets (I assume that is what you mean) are marked unhealthy from an L7 error (invalid HTTP status code), the connection is still maintained by Kong. The same goes for a connection to a remote server that has not proxied traffic in a while.

NGINX will start draining connections when the worker_connections limit is reached.

If you wish to maintain shorter lifespans for your remote connections, then have your remote servers initiate a FIN on their own. If you use NGINX upstream, you can configure its keepalive behavior via keepalive_timeout and the so_keepalive option of the listen directive. You can also tweak your remote’s kernel behavior via the net.inet.tcp.keepidle, net.inet.tcp.keepintvl and other appropriate settings.