mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
[autoscaler] Refactor multi node type autoscaler config (#10190)
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
# EXPERIMENTAL: an example of configuring a mixed-worker cluster. Currently
|
||||
# multi-worker autoscaling only works if you use the request_resources() call.
|
||||
cluster_name: auto_instance_type
|
||||
min_workers: 1
|
||||
max_workers: 40
|
||||
|
||||
# Cloud-provider specific configuration.
|
||||
provider:
|
||||
type: aws
|
||||
region: us-west-2
|
||||
availability_zone: us-west-2a
|
||||
|
||||
# Tell the autoscaler the allowed node types and the resources they provide.
|
||||
# This only has an effect if you use the experimental request_resources() call.
|
||||
available_instance_types:
|
||||
m4.xlarge:
|
||||
resources: {"CPU": 4}
|
||||
max_workers: 10
|
||||
m4.4xlarge:
|
||||
resources: {"CPU": 16, "Custom1": 1}
|
||||
max_workers: 10
|
||||
p2.xlarge:
|
||||
resources: {"CPU": 4, "GPU": 1, "Custom2": 2}
|
||||
max_workers: 4
|
||||
p2.8xlarge:
|
||||
resources: {"CPU": 32, "GPU": 8}
|
||||
max_workers: 2
|
||||
|
||||
# Configure the cluster for very conservative auto-scaling otherwise.
|
||||
target_utilization_fraction: 1.0
|
||||
idle_timeout_minutes: 2
|
||||
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: ubuntu
|
||||
|
||||
# Provider-specific config for the head node, e.g. instance type.
|
||||
head_node:
|
||||
InstanceType: m4.xlarge
|
||||
ImageId: latest_dlami
|
||||
|
||||
# Provider-specific config for the worker nodes, e.g. instance type.
|
||||
# NOTE: the instance type can be overriden by the resource demand scheduler.
|
||||
# The instance type set here is only used as the default fallback.
|
||||
worker_nodes:
|
||||
InstanceType: m4.xlarge
|
||||
ImageId: latest_dlami
|
||||
@@ -0,0 +1,66 @@
|
||||
# Experimental: an example of configuring a mixed-node-type cluster.
|
||||
cluster_name: multi_node_type
|
||||
min_workers: 1
|
||||
max_workers: 40
|
||||
|
||||
# Cloud-provider specific configuration.
|
||||
provider:
|
||||
type: aws
|
||||
region: us-west-2
|
||||
availability_zone: us-west-2a
|
||||
|
||||
# Tell the autoscaler the allowed node types and the resources they provide.
|
||||
# The key is the name of the node type, which is just for debugging purposes.
|
||||
# The node config specifies the launch config and physical instance type.
|
||||
available_node_types:
|
||||
cpu_4_ondemand:
|
||||
node_config:
|
||||
InstanceType: m4.xlarge
|
||||
resources: {"CPU": 4}
|
||||
max_workers: 5
|
||||
cpu_4_spot:
|
||||
node_config:
|
||||
InstanceType: m4.xlarge
|
||||
InstanceMarketOptions:
|
||||
MarketType: spot
|
||||
resources: {"CPU": 4}
|
||||
max_workers: 20
|
||||
cpu_16_ondemand:
|
||||
node_config:
|
||||
InstanceType: m4.4xlarge
|
||||
resources: {"CPU": 16, "Custom1": 1}
|
||||
max_workers: 10
|
||||
gpu_1_ondemand:
|
||||
node_config:
|
||||
InstanceType: p2.xlarge
|
||||
resources: {"CPU": 4, "GPU": 1, "Custom2": 2}
|
||||
max_workers: 4
|
||||
gpu_8_ondemand:
|
||||
node_config:
|
||||
InstanceType: p2.8xlarge
|
||||
resources: {"CPU": 32, "GPU": 8}
|
||||
max_workers: 2
|
||||
|
||||
# Specify the node type of the head node (as configured above).
|
||||
head_node_type: cpu_4_ondemand
|
||||
|
||||
# Specify the default type of the worker node (as configured above).
|
||||
worker_default_node_type: cpu_4_spot
|
||||
|
||||
# The default settings for the head node. This will be merged with the per-node
|
||||
# type configs given above.
|
||||
head_node:
|
||||
ImageId: latest_dlami
|
||||
|
||||
# The default settings for worker nodes. This will be merged with the per-node
|
||||
# type configs given above.
|
||||
worker_nodes:
|
||||
ImageId: latest_dlami
|
||||
|
||||
# Configure the cluster for very conservative auto-scaling otherwise.
|
||||
target_utilization_fraction: 1.0
|
||||
idle_timeout_minutes: 2
|
||||
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: ubuntu
|
||||
@@ -193,21 +193,12 @@ class AWSNodeProvider(NodeProvider):
|
||||
|
||||
self.tag_cache_update_event.set()
|
||||
|
||||
def create_node_of_type(self, node_config, tags, instance_type, count):
|
||||
assert instance_type is not None
|
||||
node_config["InstanceType"] = instance_type
|
||||
return self.create_node(node_config, tags, count)
|
||||
|
||||
def get_instance_type(self, node_config):
|
||||
return node_config["InstanceType"]
|
||||
|
||||
def create_node(self, node_config, tags, count):
|
||||
# Always add the instance type tag, since node reuse is unsafe
|
||||
# otherwise.
|
||||
tags = copy.deepcopy(tags)
|
||||
tags[TAG_RAY_INSTANCE_TYPE] = node_config["InstanceType"]
|
||||
# Try to reuse previously stopped nodes with compatible configs
|
||||
if self.cache_stopped_nodes:
|
||||
# TODO(ekl) this is breaking the abstraction boundary a little by
|
||||
# peeking into the tag set.
|
||||
filters = [
|
||||
{
|
||||
"Name": "instance-state-name",
|
||||
@@ -221,15 +212,17 @@ class AWSNodeProvider(NodeProvider):
|
||||
"Name": "tag:{}".format(TAG_RAY_NODE_TYPE),
|
||||
"Values": [tags[TAG_RAY_NODE_TYPE]],
|
||||
},
|
||||
{
|
||||
"Name": "tag:{}".format(TAG_RAY_INSTANCE_TYPE),
|
||||
"Values": [tags[TAG_RAY_INSTANCE_TYPE]],
|
||||
},
|
||||
{
|
||||
"Name": "tag:{}".format(TAG_RAY_LAUNCH_CONFIG),
|
||||
"Values": [tags[TAG_RAY_LAUNCH_CONFIG]],
|
||||
},
|
||||
]
|
||||
# This tag may not always be present.
|
||||
if TAG_RAY_INSTANCE_TYPE in tags:
|
||||
filters.append({
|
||||
"Name": "tag:{}".format(TAG_RAY_INSTANCE_TYPE),
|
||||
"Values": [tags[TAG_RAY_INSTANCE_TYPE]],
|
||||
})
|
||||
|
||||
reuse_nodes = list(
|
||||
self.ec2.instances.filter(Filters=filters))[:count]
|
||||
|
||||
Reference in New Issue
Block a user