From a680133acc39fc83e0a6d62f929ea615a95e882e Mon Sep 17 00:00:00 2001 From: Weny Xu Date: Sun, 8 Oct 2023 15:19:52 +0900 Subject: [PATCH] feat: enable no delay for mysql, opentsdb, http (#2530) * refactor: enable no delay for mysql, opentsdb, http * Apply suggestions from code review Co-authored-by: Yingwen --------- Co-authored-by: Yingwen --- src/servers/src/http.rs | 4 +++- src/servers/src/mysql/server.rs | 4 ++++ src/servers/src/opentsdb.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index 0a8dd839fa27..1e9660e93872 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -728,7 +728,9 @@ impl Server for HttpServer { app = configurator.config_http(app); } let app = self.build(app); - let server = axum::Server::bind(&listening).serve(app.into_make_service()); + let server = axum::Server::bind(&listening) + .tcp_nodelay(true) + .serve(app.into_make_service()); *shutdown_tx = Some(tx); diff --git a/src/servers/src/mysql/server.rs b/src/servers/src/mysql/server.rs index 65af7e28696a..0dd9af79dd30 100644 --- a/src/servers/src/mysql/server.rs +++ b/src/servers/src/mysql/server.rs @@ -19,6 +19,7 @@ use std::sync::Arc; use async_trait::async_trait; use auth::UserProviderRef; use common_runtime::Runtime; +use common_telemetry::error; use common_telemetry::logging::{info, warn}; use futures::StreamExt; use metrics::{decrement_gauge, increment_gauge}; @@ -137,6 +138,9 @@ impl MysqlServer { match tcp_stream { Err(error) => warn!("Broken pipe: {}", error), // IoError doesn't impl ErrorExt. Ok(io_stream) => { + if let Err(e) = io_stream.set_nodelay(true) { + error!(e; "Failed to set TCP nodelay"); + } if let Err(error) = Self::handle(io_stream, io_runtime, spawn_ref, spawn_config).await { diff --git a/src/servers/src/opentsdb.rs b/src/servers/src/opentsdb.rs index 7c569cc2ffed..61ed84167064 100644 --- a/src/servers/src/opentsdb.rs +++ b/src/servers/src/opentsdb.rs @@ -81,6 +81,9 @@ impl OpentsdbServer { async move { match stream { Ok(stream) => { + if let Err(e) = stream.set_nodelay(true) { + error!(e; "Failed to set TCP nodelay"); + } let connection = Connection::new(stream); let mut handler = Handler::new(query_handler, connection, shutdown);