-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Direct data delivery for HTTP/2 Websocket #1685
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
base: master
Are you sure you want to change the base?
Conversation
31162a1
to
cb5efcb
Compare
The current implementation moves the Websocket data through stream handlers before the Websocket process receives it and parses it. The new mechanism relays the data directly as an Erlang message without any intermediary. It also manages HTTP/2 flow control in a simpler way (it maintains it at a configured value). A new switch_protocol option (coming from the options returned from init/2) called `data_delivery` decides which mechanism to use: `stream_handlers` is the old behavior; `relay` the new. WIP: Need to test the relay mechanism in other test suites WIP: the benchmark test suite is greatly modified because I wanted to make sure Gun's poor performance was not negatively impacting results (this bit me earlier). Some tests use it, some don't, we should keep both for good measure. WIP: Other minor todos.
cb5efcb
to
316a9d7
Compare
%% - The relaying state is used by extended CONNECT protocols to | ||
%% use a 'relay' data_delivery method. | ||
%% - The stopping state indicates the stream used the 'stop' command. | ||
%% @todo Do we need to buffer data before the response is sent? Probably. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we must do this now but at least the location of this todo is wrong.
data_delivery_flow => maps:get(data_delivery_flow, Opts, 131072) | ||
}, | ||
Pid ! {{Pid, StreamID}, {switch_protocol, Headers, ?MODULE, ModState}}, | ||
%% @todo We can't call the normal takeover because it tries to parse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, we can, the buffer is empty anyway. Remove the comment or clarify it to indicate that attempting to parse is not useful.
%% Unfortunately we cannot currently cancel read_body. | ||
%% But that's OK, we will just stop reading the body | ||
%% after the next message. | ||
%% @todo We can't stop relay data_delivery currently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop of reads comes from:
- Implement a Websocket backpressure mechanism #1054
- Handle credits/conserve resources rabbitmq/rabbitmq-web-stomp#40
But to make it work with this feature we need a way to signal that we don't want to continue reading data from the stream.
The current implementation moves the Websocket data through stream handlers before the Websocket process receives it and parses it. The new mechanism relays the data directly as an Erlang message without any intermediary. It also manages HTTP/2 flow control in a simpler way (it maintains it at a configured value).
A new switch_protocol option (coming from the options returned from init/2) called
data_delivery
decides which mechanism to use:stream_handlers
is the old behavior;relay
the new.and don't increase too much. The default flow control value
will depend on that. The value must be configurable.
wanted to make sure Gun's poor performance was not negatively
impacting results (this bit me earlier). Some tests use it,
some don't, we should keep both for good measure.