You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by pa...@apache.org on 2024/07/15 07:52:53 UTC

(doris) 01/01: [Feature](rpc) support set brpc_idle_timeout_sec and enable thrift socket keep alive (#37333)

This is an automated email from the ASF dual-hosted git repository.

panxiaolei pushed a commit to branch cp_0714_4
in repository https://gitbox.apache.org/repos/asf/doris.git

commit cf3d1b1ea2a63de69e7f19d29ffd225e66ec63fd
Author: Pxl <px...@qq.com>
AuthorDate: Thu Jul 11 15:53:34 2024 +0800

    [Feature](rpc) support set brpc_idle_timeout_sec and enable thrift socket keep alive (#37333)
    
    ## Proposed changes
    In some special circumstances (such as network instability), the brpc
    server will always retain many tcp connections.
---
 be/src/common/config.cpp        | 3 +++
 be/src/common/config.h          | 1 +
 be/src/service/brpc_service.cpp | 1 +
 be/src/util/thrift_server.cpp   | 1 +
 4 files changed, 6 insertions(+)

diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 17bca94a459..eee9148e495 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -67,6 +67,9 @@ DEFINE_mString(public_access_ip, "");
 // the number of bthreads for brpc, the default value is set to -1,
 // which means the number of bthreads is #cpu-cores
 DEFINE_Int32(brpc_num_threads, "256");
+// the time of brpc server keep idle connection, setting this value too small may cause rpc between backends to fail,
+// the default value is set to -1, which means never close idle connection.
+DEFINE_Int32(brpc_idle_timeout_sec, "-1");
 
 // Declare a selection strategy for those servers have many ips.
 // Note that there should at most one ip match this list.
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 5fa5b23e977..b0f369f4c81 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -108,6 +108,7 @@ DECLARE_mString(public_access_ip);
 // the number of bthreads for brpc, the default value is set to -1,
 // which means the number of bthreads is #cpu-cores
 DECLARE_Int32(brpc_num_threads);
+DECLARE_Int32(brpc_idle_timeout_sec);
 
 // Declare a selection strategy for those servers have many ips.
 // Note that there should at most one ip match this list.
diff --git a/be/src/service/brpc_service.cpp b/be/src/service/brpc_service.cpp
index 57219f584ec..6f2dc7aea38 100644
--- a/be/src/service/brpc_service.cpp
+++ b/be/src/service/brpc_service.cpp
@@ -63,6 +63,7 @@ Status BRpcService::start(int port, int num_threads) {
     if (num_threads != -1) {
         options.num_threads = num_threads;
     }
+    options.idle_timeout_sec = config::brpc_idle_timeout_sec;
 
     if (config::enable_https) {
         auto sslOptions = options.mutable_ssl_options();
diff --git a/be/src/util/thrift_server.cpp b/be/src/util/thrift_server.cpp
index 7844f7daa1e..84173300bd1 100644
--- a/be/src/util/thrift_server.cpp
+++ b/be/src/util/thrift_server.cpp
@@ -377,6 +377,7 @@ Status ThriftServer::start() {
         server_socket = new apache::thrift::transport::TServerSocket(
                 BackendOptions::get_service_bind_address_without_bracket(), _port);
         fe_server_transport.reset(server_socket);
+        server_socket->setKeepAlive(true);
 
         if (transport_factory == nullptr) {
             transport_factory.reset(new apache::thrift::transport::TBufferedTransportFactory());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org