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 }. %%--------------------------------------------------------------------