feat(transport): Enable TCP_NODELAY. (#120)
The combination of the Nagle algorithm on a client, and delayed ack on a server can introduce up to 200ms latency if a small gRPC messages is sent with multiple writes. Enable TCP_NODELAY to make sure that neither client, nor server buffer their messages for too long when exchaning small requests.
This commit is contained in:
committed by
Lucio Franco
parent
23f648b517
commit
029950904a
@@ -427,7 +427,8 @@ struct TcpIncoming {
|
||||
|
||||
impl TcpIncoming {
|
||||
fn bind(addr: SocketAddr) -> Result<Self, crate::Error> {
|
||||
let inner = conn::AddrIncoming::bind(&addr).map_err(Box::new)?;
|
||||
let mut inner = conn::AddrIncoming::bind(&addr).map_err(Box::new)?;
|
||||
inner.set_nodelay(true);
|
||||
|
||||
Ok(Self { inner })
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use tower_service::Service;
|
||||
pub(crate) fn connector() -> HttpConnector {
|
||||
let mut http = HttpConnector::new();
|
||||
http.enforce_http(false);
|
||||
http.set_nodelay(true);
|
||||
http
|
||||
}
|
||||
|
||||
@@ -32,6 +33,7 @@ impl Connector {
|
||||
pub(crate) fn new(tls: Option<TlsConnector>) -> Self {
|
||||
let mut http = HttpConnector::new();
|
||||
http.enforce_http(false);
|
||||
http.set_nodelay(true);
|
||||
|
||||
Self { http, tls }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user