Skip to content
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

x/net/http2: graceful shutdown support to standalone HTTP/2 server #41418

Open
soya3129 opened this issue Sep 16, 2020 · 7 comments
Open

x/net/http2: graceful shutdown support to standalone HTTP/2 server #41418

soya3129 opened this issue Sep 16, 2020 · 7 comments

Comments

@soya3129
Copy link

@soya3129 soya3129 commented Sep 16, 2020

This is a feature request which follows #4674.

HTTP/2 server only supports graceful shutdown when integrated with the standard
library's HTTP Server: https://github.com/golang/net/blob/62affa334b73ec65ed44a326519ac12c421905e3/http2/server.go#L199

We have a use case where HTTP/2 server is used as a stand-alone server with ALTS instead of TLS as the security layer (https://cloud.google.com/security/encryption-in-transit/application-layer-transport-security?hl=en). It seems impossible to use the graceful shutdown feature currently even if we are willing to start a HTTP server (I could be wrong. Any idea will be very welcome!).

I think making the related functions public can easily fix the issue.

There is also some discussion around generalizing the graceful shutdown in #4674 (comment) .

@soya3129
Copy link
Author

@soya3129 soya3129 commented Sep 16, 2020

@soya3129
Copy link
Author

@soya3129 soya3129 commented Sep 16, 2020

cc @neild

@toothrot toothrot changed the title x/net/http2: graceful shutdown support to HTTP/2 server x/net/http2: graceful shutdown support to standalone HTTP/2 server Sep 16, 2020
@toothrot toothrot added this to the Backlog milestone Sep 16, 2020
@networkimprov
Copy link

@networkimprov networkimprov commented Sep 17, 2020

@fraenkel
Copy link
Contributor

@fraenkel fraenkel commented Sep 17, 2020

How are you even creating a "standalone" http2 server?

@soya3129
Copy link
Author

@soya3129 soya3129 commented Sep 18, 2020

Thanks for the attention! The standalone server calls ServeConn directly with a connection wrapped in ALTS. I was thinking if serverInternalState is public, users can call StartGracefulShutdown() directly, instead of implementing their own. Thanks!

@fraenkel
Copy link
Contributor

@fraenkel fraenkel commented Sep 18, 2020

Its not so simple. Regardless of where we could put StartGracefulShutdown(), the current code lacks most of the guards that are currently provided via http.Server. One such example is preventing new connections from being served once Shutdown is called. Exposing the current shutdown behavior just affects the current connections but does nothing to prevent new ones.

@soya3129
Copy link
Author

@soya3129 soya3129 commented Sep 18, 2020

That's right! I totally agree that to implement a complete graceful shutdown, there would be much more work.

But for the standalone use case, it would be relatively easy for users to close listeners and make sure the server waits for existing connections to close. The hard/impossible part is to trigger GOAWAYs (Please correct me if I am wrong). startGracefulShutdown() does exactly that. Instead of calling it StartGracefulShutdown(), we could call it SendGracefulGoawayOnActiveConnections(). What do you think? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.