diff --git a/conf/nebula-graphd.conf.default b/conf/nebula-graphd.conf.default index c1be4f72580..a528daa5195 100644 --- a/conf/nebula-graphd.conf.default +++ b/conf/nebula-graphd.conf.default @@ -61,6 +61,9 @@ --num_accept_threads=1 # The number of networking IO threads, 0 for # of CPU cores --num_netio_threads=0 +# Max active connections for all networking threads. 0 means no limit. +# Max connections for each networking thread = num_max_connections / num_netio_threads +--num_max_connections=0 # The number of threads to execute user queries, 0 for # of CPU cores --num_worker_threads=0 # HTTP service ip diff --git a/conf/nebula-graphd.conf.production b/conf/nebula-graphd.conf.production index 3f1d828d533..7fd8d3f6da5 100644 --- a/conf/nebula-graphd.conf.production +++ b/conf/nebula-graphd.conf.production @@ -60,6 +60,9 @@ --num_accept_threads=1 # The number of networking IO threads, 0 for # of CPU cores --num_netio_threads=0 +# Max active connections for all networking threads. 0 means no limit. +# Max connections for each networking thread = num_max_connections / num_netio_threads +--num_max_connections=0 # The number of threads to execute user queries, 0 for # of CPU cores --num_worker_threads=0 # HTTP service ip diff --git a/conf/nebula-storaged.conf.default b/conf/nebula-storaged.conf.default index 7746aef5057..0d29f5547a6 100644 --- a/conf/nebula-storaged.conf.default +++ b/conf/nebula-storaged.conf.default @@ -110,6 +110,9 @@ --auto_remove_invalid_space=true # Network IO threads number --num_io_threads=16 +# Max active connections for all networking threads. 0 means no limit. +# Max connections for each networking thread = num_max_connections / num_netio_threads +--num_max_connections=0 # Worker threads number to handle request --num_worker_threads=32 # Maximum subtasks to run admin jobs concurrently diff --git a/conf/nebula-storaged.conf.production b/conf/nebula-storaged.conf.production index a5f3f64b92a..f7f42f1093c 100644 --- a/conf/nebula-storaged.conf.production +++ b/conf/nebula-storaged.conf.production @@ -111,6 +111,9 @@ --auto_remove_invalid_space=true # Network IO threads number --num_io_threads=16 +# Max active connections for all networking threads. 0 means no limit. +# Max connections for each networking thread = num_max_connections / num_netio_threads +--num_max_connections=0 # Worker threads number to handle request --num_worker_threads=32 # Maximum subtasks to run admin jobs concurrently diff --git a/src/graph/service/GraphFlags.cpp b/src/graph/service/GraphFlags.cpp index 5b754b1bd89..22f4cbbbcda 100644 --- a/src/graph/service/GraphFlags.cpp +++ b/src/graph/service/GraphFlags.cpp @@ -17,6 +17,10 @@ DEFINE_int32(num_netio_threads, 0, "The number of networking threads, 0 for number of physical CPU cores"); DEFINE_int32(num_accept_threads, 1, "Number of threads to accept incoming connections"); +DEFINE_uint32(num_max_connections, + 0, + "Max active connections for all networking threads. 0 means no limit. Max active " + "connections for each networking thread = num_max_connections / num_netio_threads"); DEFINE_int32(num_worker_threads, 0, "Number of threads to execute user queries"); DEFINE_int32(num_operator_threads, 2, "Number of threads to execute a single operator"); DEFINE_bool(reuse_port, true, "Whether to turn on the SO_REUSEPORT option"); diff --git a/src/graph/service/GraphFlags.h b/src/graph/service/GraphFlags.h index f7a4ecf2416..3ac25c64f11 100644 --- a/src/graph/service/GraphFlags.h +++ b/src/graph/service/GraphFlags.h @@ -14,6 +14,7 @@ DECLARE_int32(session_idle_timeout_secs); DECLARE_int32(session_reclaim_interval_secs); DECLARE_int32(num_netio_threads); DECLARE_int32(num_accept_threads); +DECLARE_uint32(num_max_connections); DECLARE_int32(num_worker_threads); DECLARE_int32(num_operator_threads); DECLARE_bool(reuse_port); diff --git a/src/graph/service/GraphServer.cpp b/src/graph/service/GraphServer.cpp index 5073fdb39b8..9f211dae343 100644 --- a/src/graph/service/GraphServer.cpp +++ b/src/graph/service/GraphServer.cpp @@ -52,6 +52,7 @@ bool GraphServer::start() { thriftServer_->setReusePort(FLAGS_reuse_port); thriftServer_->setIdleTimeout(std::chrono::seconds(FLAGS_client_idle_timeout_secs)); thriftServer_->setNumAcceptThreads(FLAGS_num_accept_threads); + thriftServer_->setMaxConnections(FLAGS_num_max_connections); thriftServer_->setListenBacklog(FLAGS_listen_backlog); if (FLAGS_enable_ssl || FLAGS_enable_graph_ssl) { thriftServer_->setSSLConfig(nebula::sslContextConfig()); diff --git a/src/storage/StorageServer.cpp b/src/storage/StorageServer.cpp index 6bb98f9f76f..10f77f28419 100644 --- a/src/storage/StorageServer.cpp +++ b/src/storage/StorageServer.cpp @@ -47,6 +47,10 @@ DECLARE_string(local_ip); #endif DEFINE_bool(storage_kv_mode, false, "True for kv mode"); DEFINE_int32(num_io_threads, 16, "Number of IO threads"); +DEFINE_uint32(num_max_connections, + 0, + "Max active connections for all networking threads. 0 means no limit. Max active " + "connections for each networking thread = num_max_connections / num_netio_threads"); DEFINE_int32(storage_http_thread_num, 3, "Number of storage daemon's http thread"); DEFINE_int32(check_memory_interval_in_secs, 1, "Memory check interval in seconds"); @@ -366,6 +370,7 @@ std::unique_ptr StorageServer::getStorageServer() server->setIdleTimeout(std::chrono::seconds(0)); server->setIOThreadPool(ioThreadPool_); server->setThreadManager(workers_); + server->setMaxConnections(FLAGS_num_max_connections); if (FLAGS_enable_ssl) { server->setSSLConfig(nebula::sslContextConfig()); }