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
Spawn H2 Data frame processing into a separate task #2033
Conversation
…he Data frame is not yet received.
The changes seem reasonable but I'd like to better understand why this is necessary. In HTTP land, I guess the more common strategy is to spawn a task per client (connection) rather than one per request -- at least, that's how hyper does things, which makes sense to me. Have you looked at how this is handled for the other protocols? We should probably use the same strategy across protocols unless there are overriding reasons to do different things. |
This is not about efficiency but about preventing a deadlock. Key difference between DoH and other protocols is that it can get multiple concurrent in-flight requests on a single socket. |
Okay, so if I understand correctly the model here is that we have to keep pulling frames off the H2 connection so that it is able to (in addition to new requests) read further body chunks for previous requests? |
I think this is the relevant bit of documentation from the h2 crate:
|
Exactly. By not calling Connection::accept we are blocking new data frames. |
(The CI failures are unrelated, and addressed in #2028.) |
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.
This looks good. I'm rebasing, assuming tests are passing I'll merge after. Thanks for the PR!
I noticed that under load DoH server once in a while goes into deadlock. This is particularly visible when ECH is enabled in Chrome and it makes three simultaneous requests in a single DoH session (for A, AAAA and HTTPS records). If all Data frames do not arrive at the same time as Header frames, DoH server goes into deadlock and never responds to requests with missing data frames.
Spawning Data frame processing into a separate Tokio task resolves this issue. Same logic is actually used in the basic h2 server example at https://github.com/hyperium/h2/blob/master/examples/server.rs (line 34).