Skip to content

Commit

Permalink
feat: enable no delay for mysql, opentsdb, http (#2530)
Browse files Browse the repository at this point in the history
* refactor: enable no delay for mysql, opentsdb, http

* Apply suggestions from code review

Co-authored-by: Yingwen <[email protected]>

---------

Co-authored-by: Yingwen <[email protected]>
  • Loading branch information
WenyXu and evenyag authored Oct 8, 2023
1 parent 0593c3b commit a680133
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/servers/src/mysql/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions src/servers/src/opentsdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a680133

Please sign in to comment.