Skip to content

Commit

Permalink
[controller] Set rebalance preference to prioritize evenness when cre…
Browse files Browse the repository at this point in the history
…ating the controller cluster. Also set capacity keys to enable top-state even distribution
  • Loading branch information
kvargha committed Jan 27, 2025
1 parent 5dfe33b commit 030564e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.linkedin.venice.utils.RetryUtils;
import io.tehuti.metrics.MetricsRepository;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -99,6 +100,32 @@ public void createVeniceControllerCluster() {
// choose proper instance to hold the replica.
clusterConfig.setTopologyAwareEnabled(false);

// We want to prioritize evenness over less movement when it comes to resource assignment, because the cost
// of rebalancing for the controller is cheap as it is stateless.
Map<ClusterConfig.GlobalRebalancePreferenceKey, Integer> globalRebalancePreference = new HashMap<>();
globalRebalancePreference.put(ClusterConfig.GlobalRebalancePreferenceKey.EVENNESS, 10);
globalRebalancePreference.put(ClusterConfig.GlobalRebalancePreferenceKey.LESS_MOVEMENT, 1);
// This should be turned off, so it doesn't overpower other constraint calculations
globalRebalancePreference.put(ClusterConfig.GlobalRebalancePreferenceKey.FORCE_BASELINE_CONVERGE, 0);
clusterConfig.setGlobalRebalancePreference(globalRebalancePreference);

String resourceCapacityKey = "cluster_resource_weight";
List<String> instanceCapacityKeys = new ArrayList<>();
instanceCapacityKeys.add(resourceCapacityKey);
clusterConfig.setInstanceCapacityKeys(instanceCapacityKeys);

// This is how much capacity a participant can take. The Helix documentation recommends setting this to a high
// value to avoid rebalance failures. The primary goal of setting this is to enable a constraint that takes the
// current top-state distribution into account when rebalancing.
Map<String, Integer> defaultInstanceCapacityMap = new HashMap<>();
defaultInstanceCapacityMap.put(resourceCapacityKey, 10000);
clusterConfig.setDefaultInstanceCapacityMap(defaultInstanceCapacityMap);

// This is how much weight each resource in a cluster has
Map<String, Integer> defaultPartitionWeightMap = new HashMap<>();
defaultPartitionWeightMap.put(resourceCapacityKey, 100);
clusterConfig.setDefaultPartitionWeightMap(defaultPartitionWeightMap);

updateClusterConfigs(controllerClusterName, clusterConfig);
helixAdmin.addStateModelDef(controllerClusterName, LeaderStandbySMD.name, LeaderStandbySMD.build());

Expand Down

0 comments on commit 030564e

Please sign in to comment.