Skip to content

feat: isolate HTTP/2 receive credit within a shared budget - #1598

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:feat/http2-bounded-receive-window-isolation
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:feat/http2-bounded-receive-window-isolation

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 25, 2026

Copy link
Copy Markdown
Member

Motivation

A paused HTTP/2 stream can tie up connection receive credit and delay an independent exchange on the same connection. Netty offers connection-window auto-refill for this use case. Pekko HTTP should offer an opt-in without disabling aggregate receive accounting.

Modification

Add default-off incoming-flow-control-isolated-streams on both client and server. Reserve a share for an additional stream by limiting each stream to a share of the existing connection budget. Replenish only unbuffered, ungranted capacity. Validate the unavoidable initial HTTP/2 window and retain the existing default path and settings product shape.

Result

Application pause on a configured number of streams need not exhaust receive credit for another admitted, consuming stream. The bound is for flow-control-accounted receive buffers and granted credit, not total process memory, queued dispatched entities, or arbitrary application waits. Fits applications including the Pekko HTTP transport used by Pekko gRPC; it does not change the Netty gRPC client backend.

Tests

JDK 17, Scala 2.13.18 and Scala 3.3.9: 9 focused tests each, covering connection-credit arithmetic, configuration/defaults, client/server behavior, h2c and a public TLS HTTP/2 loopback with concurrent exchanges. MiMa on both versions, released JVM constructor/copy and Java DSL checks, formatting, Paradox and independent review passed. Full CI, external h2spec and a generated gRPC-service integration were not run locally.

Integration

If #981 or #1556 lands first, compose their internal settings carriers and retest combined options during rebase.

References

Netty #4423 and RFC 9113 §5.2.

Motivation
A paused request or response body can tie up a connection's receive credit
and delay another stream on the same connection.

Modification
Add a default-off setting for the number of paused streams to budget for.
Keep aggregate receive credit within the configured connection buffer
budget, bound each stream to a share, and replenish only from space that
is neither buffered nor already credited. Validate the unavoidable initial
HTTP/2 window without changing SETTINGS semantics.

Result
Applications can leave receive space for independent streams without
bypassing the connection budget or changing default behavior.

Tests
Check client and server frame-level credit and body completion, concurrent
calls through the public TLS HTTP/2 APIs, configuration validation and
arithmetic boundaries.

References
RFC 9113 sections 6.9.1 and 6.9.2; Netty #4423 for the motivation.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some concerns:

  • The isolation tests don't seem to show isolation. In the server/client "isolate connection receive credit from a paused request body" tests, stream 1 sends 3 × 14336 = 43008 bytes, leaving 22527 bytes of connection window even under the default controller, so stream 3's 11 bytes get through either way. Only the WINDOW_UPDATE/remaining-window assertions depend on the feature. To show the default starves stream 3, the paused stream needs to exhaust the connection window.
  • Http2ClientServerSpec "carry independent HTTP/2 calls through isolated receive windows" uses default buffers and a few bytes, so it passes identically with the option off.
  • The user-facing option is stored in the internalSettings slot, so any withInternalSettings(...) call drops it, and it collides with #981/#1556.
  • No withIncomingFlowControlIsolatedStreams (or similar) in the Scala/Java settings, unlike neighbouring settings — config-only breaks DSL parity.
  • With default sizes one paused stream can't starve the connection under the current policy. Would fixing the default refill rule be preferable to a new knob?
  • Nits: flowController changes from def to lazy val (unrelated); the pure IncomingFlowController.isolated arithmetic test would fit better in its own spec than in Http2ServerDemuxSpec.

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