[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))
@@ -14,6 +14,11 @@ max_workers: 2
# subsequent `ray up`) this number of nodes will be started.
initial_workers: 0
# Whether or not to autoscale aggressively. If this is enabled, if at any point
# we would start more workers, we start at least enough to bring us to
# initial_workers.
autoscaling_mode: default
# This executes all commands on all nodes in the docker container,
# and opens all the necessary ports to support the Ray cluster.
# Empty string means disabled.
@@ -14,6 +14,11 @@ max_workers: 2
# subsequent `ray up`) this number of nodes will be started.
initial_workers: 0
# Whether or not to autoscale aggressively. If this is enabled, if at any point
# we would start more workers, we start at least enough to bring us to
# initial_workers.
autoscaling_mode: default
# This executes all commands on all nodes in the docker container,
# and opens all the necessary ports to support the Ray cluster.
# Empty string means disabled.
@@ -14,6 +14,11 @@ max_workers: 2
# subsequent `ray up`) this number of nodes will be started.
initial_workers: 0
# Whether or not to autoscale aggressively. If this is enabled, if at any point
# we would start more workers, we start at least enough to bring us to
# initial_workers.
autoscaling_mode: default
# This executes all commands on all nodes in the docker container,
# and opens all the necessary ports to support the Ray cluster.
# Empty string means disabled.
@@ -14,6 +14,11 @@ max_workers: 2
# subsequent `ray up`) this number of nodes will be started.
initial_workers: 0
# Whether or not to autoscale aggressively. If this is enabled, if at any point
# we would start more workers, we start at least enough to bring us to
# initial_workers.
autoscaling_mode: default
# This executes all commands on all nodes in the docker container,
# and opens all the necessary ports to support the Ray cluster.
# Empty string means disabled.
@@ -2,6 +2,7 @@ cluster_name: default
min_workers: 0
max_workers: 0
initial_workers: 0
autoscaling_mode: default
docker:
image: ""
container_name: ""
+17 -14
View File
@@ -159,10 +159,11 @@ class NodeUpdater(object):
try:
logger.debug("NodeUpdater: "
"{}: Waiting for SSH...".format(self.node_id))
self.ssh_cmd(
"uptime",
connect_timeout=5,
redirect=open("/dev/null", "w"))
with open("/dev/null", "w") as redirect:
self.ssh_cmd(
"uptime", connect_timeout=5, redirect=redirect)
return True
except Exception as e:
@@ -206,12 +207,12 @@ class NodeUpdater(object):
m = "{}: Synced {} to {}".format(self.node_id, local_path,
remote_path)
with LogTimer("NodeUpdater {}".format(m)):
self.ssh_cmd(
"mkdir -p {}".format(os.path.dirname(remote_path)),
redirect=open("/dev/null", "w"),
)
self.rsync_up(
local_path, remote_path, redirect=open("/dev/null", "w"))
with open("/dev/null", "w") as redirect:
self.ssh_cmd(
"mkdir -p {}".format(os.path.dirname(remote_path)),
redirect=redirect,
)
self.rsync_up(local_path, remote_path, redirect=redirect)
# Run init commands
self.provider.set_node_tags(self.node_id,
@@ -219,13 +220,15 @@ class NodeUpdater(object):
m = "{}: Initialization commands completed".format(self.node_id)
with LogTimer("NodeUpdater: {}".format(m)):
for cmd in self.initialization_commands:
self.ssh_cmd(cmd)
with open("/dev/null", "w") as redirect:
for cmd in self.initialization_commands:
self.ssh_cmd(cmd, redirect=redirect)
m = "{}: Setup commands completed".format(self.node_id)
with LogTimer("NodeUpdater: {}".format(m)):
for cmd in self.setup_commands:
self.ssh_cmd(cmd)
with open("/dev/null", "w") as redirect:
for cmd in self.setup_commands:
self.ssh_cmd(cmd, redirect=redirect)
def rsync_up(self, source, target, redirect=None, check_error=True):
self.set_ssh_ip_if_required()