LogService supports configuring cluster-level and node-level parameters by using the LS-CTRL tool to adjust the load balancing behavior.
Enable or disable automatic rebalancing
The enable_rebalance parameter controls whether to enable log stream load balancing. It is enabled by default.
ls_ctrl -H <HOST_ADDRESS> set param enable_rebalance true
ls_ctrl -H <HOST_ADDRESS> set param enable_rebalance false
Note
In the preceding command, HOST_ADDRESS is the HTTP address (including the port number) of any LogService node, for example, 127.0.0.1:8080. For more information about LS-CTRL commands, see Overview of LS-CTRL.
Set the load balancing strategy
Use the load_balance_policy parameter to select a load balancing strategy. Valid values are replica_count_based (based on the number of replicas) and load_based (based on load). The default value is replica_count_based.
ls_ctrl -H <HOST_ADDRESS> set param load_balance_policy replica_count_based
ls_ctrl -H <HOST_ADDRESS> set param load_balance_policy load_based
Note
In the preceding command, HOST_ADDRESS is the HTTP address (including the port number) of any LogService node, for example, 127.0.0.1:8080. For more information about LS-CTRL commands, see Overview of LS-CTRL.
When the strategy is set to load_based, the disk_max_iops and disk_max_bandwidth values must be greater than 0 for all nodes in the cluster. Otherwise, the modification is rejected. If these parameters are not configured for a node in the cluster, you can set them by using the following commands:
ls_ctrl -H <HOST_ADDRESS> set param --server-only disk_max_iops <value>
ls_ctrl -H <HOST_ADDRESS> set param --server-only disk_max_bandwidth <value>
Note
- The default values of
disk_max_iopsanddisk_max_bandwidthare0, indicating that they are not configured. Before you set the strategy toload_based, make sure that both parameters are correctly set (greater than 0) for all nodes in the cluster. - After the strategy is set to
load_based, if the configuration of a node is missing at runtime (for example, a newly added node is not configured), the cluster automatically downgrades toreplica_count_basedfor scheduling and generates an ERROR log. After the configuration is complete, the cluster automatically reverts toload_based, and the displayed parameter values remain unchanged during this period.
Adjust the load balancing trigger interval
Use the rebalance_interval_sec parameter to control the trigger interval for load balancing. The default value is 60 seconds.
ls_ctrl -H <HOST_ADDRESS> set param rebalance_interval_sec 120
Note
In the preceding command, HOST_ADDRESS is the HTTP address (including the port number) of any LogService node, for example, 127.0.0.1:8080. For more information about LS-CTRL commands, see Overview of LS-CTRL.
Adjust the load balancing thresholds
The load balancing strategy uses the following two parameters to control the node resource utilization thresholds:
max_utilization_threshold: The upper limit of node resource utilization, in percentage. When the utilization exceeds this threshold, replicas are migrated out of the node. The default value is 60.min_utilization_threshold: The lower limit of node resource utilization, in percentage. When the utilization is below this threshold, only UnderUtilized events are recorded for observation, and no action is triggered. The default value is 30.
ls_ctrl -H <HOST_ADDRESS> set param max_utilization_threshold 70
ls_ctrl -H <HOST_ADDRESS> set param min_utilization_threshold 20
Note
In the preceding command, HOST_ADDRESS is the HTTP address (including the port number) of any LogService node, for example, 127.0.0.1:8080. For more information about LS-CTRL commands, see Overview of LS-CTRL.
Considerations
- All cluster-level parameter modifications take effect immediately without requiring a node restart.
- Node-level parameters
disk_max_iopsanddisk_max_bandwidthtake effect immediately when modified, but you must use the--server-onlyparameter. - When modifying the load balancing strategy, ongoing balancing/scheduling tasks continue according to the old strategy without interruption.
- Parameter values are case-sensitive.