Skip to content

Improve HTTP/2 GOAWAY handling to close idle connections early during graceful shutdown #6388

@yzfeng2020

Description

@yzfeng2020

Currently, when an HTTP/2 server connection enters graceful shutdown (after sending GOAWAY), it always waits for the full connectionDrainDuration before closing the connection, even if there are no active requests. This leads to unnecessary resource consumption and slower connection cleanup during server shutdown or connection recycling scenarios.

Current behavior

  1. Server sends initial GOAWAY frame with stream ID Integer.MAX_VALUE to signal imminent shutdown
  2. Waits for the full drain duration
  3. Sends final GOAWAY and closes connection

Proposed Improvement

Implement an event-driven mechanism to close HTTP/2 connections immediately when no active requests remain during the drain phase. This would:

  1. Track active requests during connection draining
  2. Fire an event when the last active request completes (or immediately if no requests are active when draining starts)
  3. Cancel the scheduled drain timeout and close the connection early

Please let me know if my understanding is correct and if the proposal is reasonbale!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions