Skip to content

Implement two-phase graceful HTTP/2 shutdown#654

Closed
arturobernalg wants to merge 1 commit intoapache:masterfrom
arturobernalg:two-phase
Closed

Implement two-phase graceful HTTP/2 shutdown#654
arturobernalg wants to merge 1 commit intoapache:masterfrom
arturobernalg:two-phase

Conversation

@arturobernalg
Copy link
Copy Markdown
Member

This change implements two-phase graceful shutdown for HTTP/2 connections.
The multiplexer sends an initial GOAWAY, waits one RTT using PING, then sends the final GOAWAY with the last processed stream identifier while continuing to handle in-flight peer streams and peer GOAWAY boundaries correctly.

Send an initial GOAWAY, wait one RTT using PING, then send the final GOAWAY with the last processed stream id.
@arturobernalg arturobernalg requested a review from ok2c March 18, 2026 06:06
@ok2c
Copy link
Copy Markdown
Member

ok2c commented Mar 19, 2026

@arturobernalg Why is this needed? What does this improve excactly?

@arturobernalg
Copy link
Copy Markdown
Member Author

Why is this needed? What does this improve excactly?

@ok2c
RFC 9113 recommends two-phase graceful shutdown for HTTP/2: initial GOAWAY with 2^31-1, wait one RTT, then final GOAWAY with the actual last processed stream id. This improves correctness of connection draining by avoiding shutdown races around in-flight stream creation and by preserving an accurate final GOAWAY boundary.

https://www.rfc-editor.org/rfc/rfc9113.html#section-6.8

“A server that is attempting to gracefully shut down a connection SHOULD send an initial GOAWAY frame with the last stream identifier set to 2^31-1 and a NO_ERROR code.”

“After allowing time for any in-flight stream creation (at least one round-trip time), the server MAY send another GOAWAY frame with an updated last stream identifier.”

@ok2c
Copy link
Copy Markdown
Member

ok2c commented Mar 19, 2026

A server that is attempting

@arturobernalg Very well. A server. And what about clients? Does this make any sense for client connections?

@arturobernalg
Copy link
Copy Markdown
Member Author

A server that is attempting

@arturobernalg Very well. A server. And what about clients? Does this make any sense for client connections?

Good point.For client connections, sending GOAWAY on graceful close still makes sense, but the two-phase drain logic appears to have much less practical value except perhaps for server push.

@ok2c
Copy link
Copy Markdown
Member

ok2c commented Apr 1, 2026

@arturobernalg What I was trying to say this feature would make more sense for the server side and so much for the client side, where it would just slow down connection termination. It may still be worth looking at but for the server side only.

@arturobernalg
Copy link
Copy Markdown
Member Author

Hi @ok2c

I updated the patch to restrict the two-phase graceful shutdown logic to server-side connections only.
The server now sends an initial GOAWAY, waits one RTT using PING, and then sends the final GOAWAY with the last processed stream id. Client-side graceful shutdown remains a single-GOAWAY path. Please take a look #661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants