[DEV-1765] Set TCP_NODELAY on HttpConnector to disable Nagle's algorithm#233
Merged
Conversation
PR Summary by QodoEnable TCP_NODELAY on gRPC HttpConnector to reduce latency WalkthroughsDescription• Enable TCP_NODELAY on the gRPC HttpConnector to avoid Nagle/delayed-ACK latency. • Align custom hyper client behavior with tonic Channel defaults. • Reduce tail latency for small gRPC request/response traffic without changing TLS/auth/payload. Diagramgraph TD
A["NodeConnection::new"] --> B["HttpConnector"] --> C["TCP socket"]
B --> D["TCP_NODELAY=true"]
subgraph Legend
direction LR
_fn["Function"] ~~~ _cmp["Component"] ~~~ _net["Network"]
end
High-Level AssessmentThe following are alternative approaches to this PR: 1. Expose TCP_NODELAY as a user-configurable knob
2. Use tonic::transport::Channel builder directly (avoid custom connector)
Recommendation: Setting http.set_nodelay(true) in the existing custom HttpConnector is the best near-term fix: it’s minimal, matches tonic defaults, and addresses the documented Nagle/delayed-ACK latency issue without widening the public API. Consider making it configurable only if future use-cases require toggling. File ChangesBug fix (1)
|
8b53fa5 to
0b6cbc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NodeConnection::newbuilds a custom hyper client whoseHttpConnectornever enablesTCP_NODELAY(grpc.rs:897), so Nagle's algorithm stays on for every gRPC connection. Nagle's interaction with delayed ACKs is a documented cause of latency for small request/response traffic like gRPC, withTCP_NODELAYas the standard mitigation.This sets
http.set_nodelay(true), which matches tonic'stransport::Channeldefault. It only affects when small segments are flushed, with no change to TLS, auth, or payload.Closes #232
Additional resources: