[PATCH cluster v4 03/28] datacenter config: add auto rebalancing options

Daniel Kral
2026-04-02T12:49:40Z

These options control the behavior of the load balancing system in the
HA Manager.

The imbalance threshold default value is set to `0.3`, as
experimentation with some common cluster sizes showed good results. This
might need more adaption in the future, such as a cluster-size-dependent
profile setting to find a better threshold default value.

Another inbalance threshold default value, which was considered, was
`0.15`, which is the minimum threshold to detect an imbalance in a
cluster with one node with load 0.0 and the other nodes with load 1.0
for a cluster size of up to 45 nodes. For cluster size N, this is
derived with:

node_loads = [0.0] + [1.0 for _ in range(N-1)]
min_imbalance = calculate_node_imbalance(node_loads)

Though a good starting metric, the imbalance threshold of `0.15` would
be too sensitive for small cluster sizes and `0.3` was a better balance
for that.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
changes v3 -> v4:
- change threshold default value from 0.7 to 0.3
- add minimum requirements to number fields

src/PVE/DataCenterConfig.pm | 44 +++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)

diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm
index 0225bc6..6513594 100644
--- a/src/PVE/DataCenterConfig.pm
+++ b/src/PVE/DataCenterConfig.pm
@@ -33,6 +33,50 @@ EODESC
"Set to use CRS for selecting a suited node when a HA services request-state"
. " changes from stop to start.",
},
+ 'ha-auto-rebalance' => {
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ description => "Whether to use CRS for balancing HA resources automatically"
+ . " depending on the current node imbalance.",
+ },
+ 'ha-auto-rebalance-threshold' => {
+ type => 'number',
+ optional => 1,
+ minimum => 0.0,
+ default => 0.3,
+ requires => 'ha-auto-rebalance',
+ description => "The threshold for the cluster node imbalance, which will"
+ . " trigger the automatic resource balancing system if its value"
+ . " is exceeded.",
+ },
+ 'ha-auto-rebalance-method' => {
+ type => 'string',
+ enum => ['bruteforce', 'topsis'],
+ optional => 1,
+ default => 'bruteforce',
+ requires => 'ha-auto-rebalance',
+ description => "The method to use for the scoring of balancing migrations.",
+ },
+ 'ha-auto-rebalance-hold-duration' => {
+ type => 'number',
+ optional => 1,
+ minimum => 0,
+ default => 3,
+ requires => 'ha-auto-rebalance',
+ description => "The number of HA rounds for which the cluster node"
+ . " imbalance threshold must be exceeded before triggering an"
+ . " automatic resource balancing migration.",
+ },
+ 'ha-auto-rebalance-margin' => {
+ type => 'number',
+ optional => 1,
+ minimum => 0.0,
+ default => 0.1,
+ requires => 'ha-auto-rebalance',
+ description => "The minimum relative improvement in cluster node"
+ . " imbalance to commit to a resource balancing migration.",
+ },
};

my $migration_format = {
--
2.47.3