-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graceful shutdown of keep-alive connections #18890
Comments
@stuartwdouglas looks like something for you. |
@stuartwdouglas thanks for very quick reaction. May be I am wrong here but is placement of your fix right? Of course when 503 is returned it doesn't hurt to add Connection: close. But this is case of completely new connection. I was mainly thinking about existing connections which are open with keep alive. Once current request in such connection is done it should be closed by Connection: close header. Therefore I think right place to add header is requestDoneHandler. Isn't it? |
responseDoneHandler is called when the response is done (i.e. has been sent to the client). You can't add a header to the connections that are currently being processed, they are likely being processed by different threads so any attempt to modify the non thread safe header map from another thread would cause all kinds of problems, and in general tracking this is way more expensive than the the counter approach. |
Sorry for being so stubborn. How will this affect currently open connections with http keep alive? Those connections are open and clients are allowed to send requests through them. (Clients are not aware of running shutdown.)
As far as I understand current code and behavior of application point 4 is problem since we are already in shutdown grace period but we are not informing clients to close connection. In such case we will probably still reply with HTTP 200 which is OK, but information about closing connection should be added. In current implementation with your fix information about closing will be added only in combination with HTTP 503. |
Basically what happens is:
|
Description
Currently there is support for graceful shutdown implemented in io.quarkus.vertx.http.runtime.filters.GracefulShutdownFilter it waits for all requests to finish and only then (except timeout) terminate the application. This works well.
If I am not mistaken it only counts requests and lets connections to be closed by underlying implementation (Vertx). But in case connections are open with keep alive connections are not closed. Or at least such information is not sent to client in form of header Connection: close
Implementation ideas
io.quarkus.vertx.http.runtime.filters.GracefulShutdownFilter could add header Connection: close in case its internal state is indicating shutdown (running == false). This can be done either unconditionally as it probably won't cause any problems to clients not using keep alive. Or (and here I am not sure) only in case connection is open with keep alive.
The text was updated successfully, but these errors were encountered: