Skip to content
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

Set TCP_NODELAY on the TcpStream to disable Nagle's algorithm. #900

Closed
wants to merge 1 commit into from

Conversation

kyrias
Copy link
Contributor

@kyrias kyrias commented Sep 9, 2022

Due to the way the async-h1 crate writes HTTP responses to the TcpStream the head and body end up in separate write calls to the underlying socket. If we're responding to more than one request received from the same TcpStream it means that we did two sends and then tried to read. That read can take up to 500 milliseconds to complete due to bad interactions between Nagle's algorithm and delayed ACK. (In practice this is 40 ms on Linux.)

Disabling Nagle's algorithm works around this until async-h1 is fixed.

http-rs/async-h1#199

Due to the way the `async-h1` crate writes HTTP responses to the `TcpStream` the head
and body end up in separate write calls to the underlying socket.  If we're responding
to more than one request received from the same `TcpStream` it means that we did two
sends and then tried to read.  That read can take up to 500 milliseconds to complete due
to bad interactions between Nagle's algorithm and delayed ACK.  (In practice this is 40
ms on Linux.)

Disabling Nagle's algorithm works around this until `async-h1` is fixed.

http-rs/async-h1#199

Signed-off-by: Johannes Löthberg <[email protected]>
@kyrias
Copy link
Contributor Author

kyrias commented Dec 30, 2022

Finally got around to figuring out how to fix this properly in async-h1. C.f. http-rs/async-h1#200

@kyrias kyrias closed this Dec 30, 2022
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.

1 participant