From 36b3a443b74bb3ef966fc9fb0fdc9ea4c4a8cebf Mon Sep 17 00:00:00 2001 From: terry-xiaoyu <506895667@qq.com> Date: Fri, 17 Jan 2020 16:31:14 +0800 Subject: [PATCH] Reduce default tcp client nums to schedulers/2 --- etc/emqx.conf | 5 +++-- priv/emqx.schema | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index 1e5136228..e8d59cb65 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -327,10 +327,11 @@ rpc.tcp_server_port = 5369 ## Value: Port [1024-65535] rpc.tcp_client_port = 5369 -## Number of utgoing RPC connections. +## Number of Outgoing RPC connections. ## ## Value: Interger [1-256] -rpc.tcp_client_num = 32 +## Defaults to NumberOfCPUSchedulers / 2 +#rpc.tcp_client_num = 1 ## RCP Client connect timeout. ## diff --git a/priv/emqx.schema b/priv/emqx.schema index fb05700c5..a7f53ba1f 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -362,11 +362,18 @@ end}. %% Default TCP port for outgoing connections {mapping, "rpc.tcp_client_num", "gen_rpc.tcp_client_num", [ - {default, 32}, + {default, 0}, {datatype, integer}, {validators, ["range:gt_0_lt_256"]} ]}. +{translation, "gen_rpc.tcp_client_num", fun(Conf) -> + case cuttlefish:conf_get("rpc.tcp_client_num", Conf) of + 0 -> max(1, erlang:system_info(schedulers) div 2); + V -> V + end +end}. + %% Client connect timeout {mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [ {default, "5s"}, @@ -428,7 +435,7 @@ end}. ]}. {validator, "range:gt_0_lt_256", "must greater than 0 and less than 256", - fun(X) -> X > 0 andalso X < 256 end + fun(X) -> X >= 0 andalso X < 256 end }. %%--------------------------------------------------------------------