[autoscaler] Add an aggressive_autoscaling flag (#4285)

This commit is contained in:
Daniel Edgecumbe
2019-04-13 18:44:32 -07:00
committed by Robert Nishihara
parent 56a78baf67
commit 3e1adafbce
11 changed files with 113 additions and 17 deletions
+9 -2
View File
@@ -51,6 +51,9 @@ CLUSTER_CONFIG_SCHEMA = {
# The number of workers to launch initially, in addition to the head node.
"initial_workers": (int, OPTIONAL),
# The mode of the autoscaler e.g. default, aggressive
"autoscaling_mode": (str, OPTIONAL),
# The autoscaler will scale up the cluster to this target fraction of
# resources usage. For example, if a cluster of 8 nodes is 100% busy
# and target_utilization was 0.8, it would resize the cluster to 10.
@@ -519,9 +522,13 @@ class StandardAutoscaler(object):
ideal_num_nodes = int(np.ceil(cur_used / float(target_frac)))
ideal_num_workers = ideal_num_nodes - 1 # subtract 1 for head node
initial_workers = self.config["initial_workers"]
aggressive = self.config["autoscaling_mode"] == "aggressive"
if self.bringup:
ideal_num_workers = max(ideal_num_workers,
self.config["initial_workers"])
ideal_num_workers = max(ideal_num_workers, initial_workers)
elif aggressive and cur_used > 0:
# If we want any workers, we want at least initial_workers
ideal_num_workers = max(ideal_num_workers, initial_workers)
return min(self.config["max_workers"],
max(self.config["min_workers"], ideal_num_workers))