1

We have a setup that looks like this:

Client -> AWS ELB (tcp load balancing)-> NGINX (ssl termination) -> application server.

We want to gracefully take application servers out of the load balancer. We do this by having a health check that responds with 503 when the node is about to shut down, while allowing any pending requests to complete.

However, since nginx is configured to use keep-alive, clients that have already established a connection may continue to send new requests, even after the node has been taken out of the load balancer.

Setting the Connection: close header in all responses from the application server does not help, as nginx (rightfully, according to the RFC) does not pass that on to the client.

Is there any other way, but to disable keep-alive altogether?

0

We solved this by updating the nginx config to disable keep-alive (by setting both keepalive_requests and keepalive_timeout to 0) and then reload nginx as part of the application shutdown procedure.

It would probably be enough to simply reload the configuration, given that nginx fires up a new worker process when reloading, and only keeps the old worker(s) around until they have finished their ongoing requests.

2
  • What exactly did you configure to disable keep-alive? Thanks!
    – derFunk
    Jul 27 '16 at 15:29
  • @derFunk: Updated the answer to include the information you asked about. Jul 29 '16 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.