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 <realevenyag@gmail.com>

---------

Co-authored-by: Yingwen <realevenyag@gmail.com>
This commit is contained in:
Weny Xu
2023-10-08 15:19:52 +09:00
committed by GitHub
parent 0593c3bde3
commit a680133acc
3 changed files with 10 additions and 1 deletions

View File

@@ -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);

View File

@@ -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
{

View File

@@ -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);