Reduce default tcp client nums to schedulers/2

This commit is contained in:
terry-xiaoyu 2020-01-17 16:31:14 +08:00 committed by Shawn
parent 050a3feab2
commit 36b3a443b7
2 changed files with 12 additions and 4 deletions

View File

@ -327,10 +327,11 @@ rpc.tcp_server_port = 5369
## Value: Port [1024-65535] ## Value: Port [1024-65535]
rpc.tcp_client_port = 5369 rpc.tcp_client_port = 5369
## Number of utgoing RPC connections. ## Number of Outgoing RPC connections.
## ##
## Value: Interger [1-256] ## Value: Interger [1-256]
rpc.tcp_client_num = 32 ## Defaults to NumberOfCPUSchedulers / 2
#rpc.tcp_client_num = 1
## RCP Client connect timeout. ## RCP Client connect timeout.
## ##

View File

@ -362,11 +362,18 @@ end}.
%% Default TCP port for outgoing connections %% Default TCP port for outgoing connections
{mapping, "rpc.tcp_client_num", "gen_rpc.tcp_client_num", [ {mapping, "rpc.tcp_client_num", "gen_rpc.tcp_client_num", [
{default, 32}, {default, 0},
{datatype, integer}, {datatype, integer},
{validators, ["range:gt_0_lt_256"]} {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 %% Client connect timeout
{mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [ {mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [
{default, "5s"}, {default, "5s"},
@ -428,7 +435,7 @@ end}.
]}. ]}.
{validator, "range:gt_0_lt_256", "must greater than 0 and less than 256", {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
}. }.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------