Bladeren bron

Reduce default tcp client nums to schedulers/2

terry-xiaoyu 6 jaren geleden
bovenliggende
commit
36b3a443b7
2 gewijzigde bestanden met toevoegingen van 12 en 4 verwijderingen
  1. 3 2
      etc/emqx.conf
  2. 9 2
      priv/emqx.schema

+ 3 - 2
etc/emqx.conf

@@ -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.
 ##
 ##

+ 9 - 2
priv/emqx.schema

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