Skip to content

Support strict thread mode for HTTP/2 server streams - #6368

Open
doxlik wants to merge 1 commit into
eclipse-vertx:masterfrom
doxlik:http2-strict-thread-mode
Open

doxlik wants to merge 1 commit into
eclipse-vertx:masterfrom
doxlik:http2-strict-thread-mode

Conversation

@doxlik

@doxlik doxlik commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

When the server runs in strict thread mode with the event-loop threading model, a stream bound to the connection event-loop is exclusively written from that thread, therefore the outbound message queue is not needed: messages can be relayed to the connection directly, like HTTP/1 does.

The outbound queue of DefaultHttp2Stream becomes an OutboundWriteQueue with two implementations: QueuedWriteQueue, the existing OutboundMessageQueue, and DirectWriteQueue, which writes without queueing and rejects writes performed from another thread. Frames the stream window cannot accommodate are held by the Netty flow controller instead, which also fails their promises when the stream is reset.

HttpServerResponseImpl checks the calling thread before it mutates any state, so that a rejected write leaves the response usable.

Measured on a hello world server:

Setup h2load Before After
8 event loops -c8 -m128 2.14M req/s 2.48M req/s
16 event loops -c16 -m128 2.42M req/s 2.8-3M req/s

Resolves #6369

When the server runs in strict thread mode with the event-loop threading
model, a stream bound to the connection event-loop is exclusively written
from that thread, therefore the outbound message queue is not needed:
messages can be relayed to the connection directly, like HTTP/1 does.

The outbound queue of DefaultHttp2Stream becomes an OutboundWriteQueue with
two implementations: QueuedWriteQueue, the existing OutboundMessageQueue, and
DirectWriteQueue, which writes without queueing and rejects writes performed
from another thread. Frames the stream window cannot accommodate are held by
the Netty flow controller instead, which also fails their promises when the
stream is reset.

HttpServerResponseImpl checks the calling thread before it mutates any state,
so that a rejected write leaves the response usable.

Signed-off-by: doxlik <doxlikx@gmail.com>
@doxlik

doxlik commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@vietj Hi. Please have a look once you have time.

@vietj

vietj commented Sep 18, 2026

Copy link
Copy Markdown
Member

actually I am not sure to keep this feature in vertx because I think it will raise too many issues on the long term to support it.

@vietj

vietj commented Sep 18, 2026

Copy link
Copy Markdown
Member

also if I would merge that, before I would like to perform some work on the HTTP stream API to make more efficient ByteBuf <-> Object conversion for gRPC which means in practice rewriting some internals.

So allow me for now to park this PR until further notice.

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.

Support strict thread mode for HTTP/2 server streams

2 participants