Vertex AI에서 Ray 클러스터를 확장하는 방법에는 자동 확장과 수동 확장이라는 두 가지 옵션이 있습니다. 자동 확장을 사용하면 클러스터가 예를 들어 Ray 작업 및 행위에 필요한 리소스를 기반으로 워커 노드 수를 자동으로 조정할 수 있습니다. 워크로드가 많고 필요한 리소스가 확실하지 않은 경우 자동 확장이 권장됩니다.
수동 확장을 사용하면 노드를 더 세부적으로 제어할 수 있습니다.
자동 확장은 워크로드 비용을 줄일 수 있지만 노드 실행 오버헤드를 추가하며 구성하기가 까다로울 수 있습니다. Ray를 처음 사용하는 경우 자동 확장 처리가 아닌 클러스터로 시작하고 수동 확장 기능을 사용하는 것이 좋습니다.
자동 확장
워커 풀의 최소 복제본 수(min_replica_count) 및 최대 복제본 수(max_replica_count)를 지정하여 Ray 클러스터의 자동 확장 기능을 사용 설정할 수 있습니다.
다음 사항을 참고하세요.
모든 작업자 풀의 자동 확장 사양을 구성해야 합니다.
커스텀 업스케일링 및 다운스케일링 속도는 지원되지 않습니다. 기본값은 Ray 문서의 업스케일링 및 다운스케일링 속도를 참조하세요.
작업자 풀 자동 확장 사양 설정
Google Cloud 콘솔 또는 Vertex AI SDK for Python를 사용하여 Ray 클러스터의 자동 확장 기능을 사용 설정할 수 있습니다.
Vertex AI SDK의 Ray
fromgoogle.cloudimportaiplatformimportvertex_rayfromvertex_rayimportAutoscalingSpecautoscaling_spec=AutoscalingSpec(min_replica_count=1,max_replica_count=3,)head_node_type=Resources(machine_type="n1-standard-16",node_count=1,)worker_node_types=[Resources(machine_type="n1-standard-16",accelerator_type="NVIDIA_TESLA_T4",accelerator_count=1,autoscaling_spec=autoscaling_spec,)]# Create the Ray cluster on Vertex AICLUSTER_RESOURCE_NAME=vertex_ray.create_ray_cluster(head_node_type=head_node_type,worker_node_types=worker_node_types,...)
콘솔
OSS Ray 권장사항에 따라 Ray 헤드 노드에서 논리적 CPU 수를 0으로 설정하면 헤드 노드에서 워크로드가 강제로 실행되지 않습니다.
클러스터 만들기 패널의 각 단계에서 기본 클러스터 정보를 검토하거나 바꿉니다. 계속을 클릭하여 각 단계를 완료합니다.
이름 및 리전에서 이름을 지정하고 클러스터의 위치를 선택합니다.
컴퓨팅 설정에서 머신 유형, 가속기 유형 및 수, 디스크 유형 및 크기, 복제본 수를 포함하여 헤드 노드에서 Ray 클러스터의 구성을 지정합니다. 원하는 경우 커스텀 이미지 URI를 추가하여 커스텀 컨테이너 이미지를 지정하여 기본 컨테이너 이미지에서 제공하지 않는 Python 종속 항목을 추가할 수 있습니다. 커스텀 이미지를 참조하세요.
학습 중에 워크로드의 리소스 통계를 모니터링할 필요가 없는 경우 측정항목 수집을 사용 중지합니다.
자동 확장 작업자 풀이 있는 클러스터를 만들려면 작업자 풀의 최대 복제본 수를 지정합니다.
만들기를 클릭합니다.
수동 확장
Vertex AI 기반 Ray 클러스터에서 워크로드가 급증하거나 감소하면 수요에 맞게 복제본 수를 수동으로 확장할 수 있습니다. 예를 들어 용량이 초과된 경우 작업자 풀을 축소하여 비용을 절감합니다.
VPC 피어링 제한사항
클러스터를 확장할 때 기존 작업자 풀의 복제본 수만 변경할 수 있습니다. 예를 들어 클러스터에서 작업자 풀을 추가 또는 삭제하거나 작업자 풀의 머신 유형을 변경할 수 없습니다. 또한 작업자 풀에 대한 복제본 수는 1보다 작을 수 없습니다.
VPC 피어링 연결을 사용하여 클러스터에 연결하는 경우 최대 노드 수에 제한이 있습니다. 최대 노드 수는 클러스터가 생성될 때의 클러스터에 있던 노드 수에 따라 다릅니다. 자세한 내용은 최대 노드 수 계산을 참조하세요.
이 최대 수에는 작업자 풀뿐만 아니라 헤드 노드도 포함됩니다.
기본값 네트워크 구성을 사용하는 경우 노드 수는
클러스터 만들기 문서에 설명된 상한값을
초과할 수 없습니다.
최대 노드 수 계산
비공개 서비스 액세스(VPC 피어링)를 사용하여 노드에
연결하는 경우, f(x) = min(29, (32 -
ceiling(log2(x)))라고 가정하고 다음 수식을 사용하여
최대 노드 수(M)를 초과하지 않는지 확인하세요.
f(2 * M) = f(2 * N)
f(64 * M) = f(64 * N)
f(max(32, 16 + M)) = f(max(32, 16 + N))
수직 확장할 수 있는 Vertex AI 기반 Ray 클러스터의 최대 총 노드 수(M)는 설정한 초기 총 노드 수(N)에 따라 다릅니다. Vertex AI 기반 Ray 클러스터를 만든 후 총 노드 수를 P에서 M(포함) 사이의 값으로 확장할 수 있습니다. 여기서 P는 클러스터의 풀 수입니다.
클러스터의 초기 총 노드 수와 수직 확장 타겟 수는 동일한 색상 블록에 있어야 합니다.
복제본 수 업데이트
Google Cloud 콘솔 또는 Vertex AI SDK for Python을 사용하여 작업자 풀의 복제본 수를 업데이트할 수 있습니다. 클러스터에 여러 작업자 풀이 포함된 경우 단일 요청에서 각 복제본 수를 개별적으로 변경할 수 있습니다.
Vertex AI SDK의 Ray
importvertexaiimportvertex_rayvertexai.init()cluster=vertex_ray.get_ray_cluster("CLUSTER_NAME")# Get the resource name.cluster_resource_name=cluster.cluster_resource_name# Create the new worker poolsnew_worker_node_types=[]forworker_node_typeincluster.worker_node_types:worker_node_type.node_count=REPLICA_COUNT# new worker pool sizenew_worker_node_types.append(worker_node_type)# Make update callupdated_cluster_resource_name=vertex_ray.update_ray_cluster(cluster_resource_name=cluster_resource_name,worker_node_types=new_worker_node_types,)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Scale Ray clusters on Vertex AI\n\nRay clusters on Vertex AI offer two scaling options:\nand\n.\nAutoscaling lets the cluster automatically adjust the number of worker nodes\nbased on the resources the Ray tasks and actors require. If you run a heavy workload and are unsure of the resources needed, autoscaling is recommended. Manual\nscaling gives users more granular control of the nodes.\n\nAutoscaling can reduce workload costs but adds node launch overhead and can be\ntricky to configure. If you are new to Ray, start with non-autoscaling clusters,\nand use the manual scaling feature.\n| **Note:** Manual scaling has a limitation due to VPC peering. Google recommends using a [Private Service Connect interface](/vertex-ai/docs/open-source/ray-on-vertex-ai/create-cluster#use-psc-i-egress) when you implement a private VPC network.\n\nAutoscaling\n-----------\n\nEnable a Ray cluster's autoscaling feature by specifying the minimum replica\ncount (`min_replica_count`) and maximum replica count (`max_replica_count`) of\na worker pool.\n\nNote the following:\n\n- Configure the autoscaling specification of all worker pools.\n- Custom upscaling and downscaling speed is not supported. For default values, see [Upscaling and downscaling speed](https://docs.ray.io/en/latest/cluster/vms/user-guides/configuring-autoscaling.html#upscaling-and-downscaling-speed) in the Ray documentation.\n\n### Set worker pool autoscaling specification\n\nUse the Google Cloud console or\n\nto enable a Ray cluster's autoscaling feature. \n\n### Ray on Vertex AI SDK\n\n```python\nfrom google.cloud import aiplatform\nimport vertex_ray\nfrom vertex_ray import AutoscalingSpec\n\nautoscaling_spec = AutoscalingSpec(\n min_replica_count=1,\n max_replica_count=3,\n)\n\nhead_node_type = Resources(\n machine_type=\"n1-standard-16\",\n node_count=1,\n)\n\nworker_node_types = [Resources(\n machine_type=\"n1-standard-16\",\n accelerator_type=\"NVIDIA_TESLA_T4\",\n accelerator_count=1,\n autoscaling_spec=autoscaling_spec,\n)]\n\n# Create the Ray cluster on Vertex AI\nCLUSTER_RESOURCE_NAME = vertex_ray.create_ray_cluster(\nhead_node_type=head_node_type,\nworker_node_types=worker_node_types,\n...\n)\n```\n\n### Console\n\nIn accordance with the\n[OSS Ray best practice](https://docs.ray.io/en/latest/cluster/vms/user-guides/large-cluster-best-practices.html#configuring-the-head-node)\nrecommendation, setting the logical CPU count to 0 on the Ray head node is enforced in order\nto avoid running any workload on the head node.\n\n1. In the Google Cloud console, go to the Ray on Vertex AI page.\n\n [Go to the Ray on Vertex AI page](https://console.cloud.google.com/vertex-ai/ray)\n2. Click **Create cluster** to open the **Create cluster** panel.\n\n3. For each step in the **Create cluster** panel, review or replace the\n default cluster information. Click **Continue** to complete each step:\n\n 1. For **Name and region** , specify a **Name** and choose a location for your cluster.\n 2. For **Compute settings** , specify the configuration of the Ray cluster\n on the head node, including its machine type, accelerator type and\n count, disk type and size, and replica count. Optionally, add a custom\n image URI to specify a custom container image to add Python\n dependencies not provided by the default container image. See\n [Custom image](/vertex-ai/docs/open-source/ray-on-vertex-ai/create-cluster#custom-image).\n\n Under **Advanced options**, you can:\n - Specify your own encryption key.\n - Specify a [custom service account](/vertex-ai/docs/general/custom-service-account).\n - If you don't need to monitor the resource statistics of your workload during training, disable the metrics collection.\n 3. To create a cluster with an autoscaling worker pool, provide a value\n for the worker pool's maximum replica count.\n\n4. Click **Create**.\n\nManual scaling\n--------------\n\nAs your workloads surge or decrease on your Ray clusters on Vertex AI,\nmanually scale the number of replicas to match demand. For example, if you have\nexcess capacity, scale down your worker pools to save costs.\n\n### Limitations with VPC Peering\n\nWhen you scale clusters, you can change only the number of replicas in your\nexisting worker pools. For example, you can't add or remove worker pools from\nyour cluster or change the machine type of your worker pools. Also, the number\nof replicas for your worker pools can't be lower than one.\n\nIf you use a VPC peering connection to connect to your clusters,\na limitation exists on the maximum number of nodes. The maximum number of nodes\ndepends on the number of nodes the cluster had when you created the cluster. For\nmore information, see [Max number of nodes calculation](#calc). This maximum\nnumber includes not just your worker pools but also your head node. If you use\nthe default network configuration, the number of nodes can't exceed the upper\nlimits as described in the [create clusters](/vertex-ai/docs/open-source/ray-on-vertex-ai/create-cluster)\ndocumentation.\n\n#### Maximum number of nodes calculation\n\nIf you use private services access (VPC peering) to connect to\nyour nodes, use the following formulas to check that you don't exceed the\nmaximum number of nodes (`M`), assuming `f(x) = min(29, (32 -\nceiling(log2(x)))`:\n\n- `f(2 * M) = f(2 * N)`\n- `f(64 * M) = f(64 * N)`\n- `f(max(32, 16 + M)) = f(max(32, 16 + N))`\n\nThe maximum total number of nodes in the Ray on Vertex AI cluster you can\nscale up to (`M`) depends on the initial total number of nodes you set up (`N`).\nAfter you create the Ray on Vertex AI cluster, you can scale the total\nnumber of nodes to any amount between `P` and `M` inclusive, where `P` is the\nnumber of pools in your cluster.\n\nThe initial total number of nodes in the cluster and the scaling up target\nnumber must be in the same color block.\n\n### Update replica count\n\nUse the Google Cloud console or Vertex AI SDK for Python to update your worker\npool's replica count. If your cluster includes multiple worker pools, you can\nindividually change each of their replica counts in a single request. \n\n### Ray on Vertex AI SDK\n\n```python\nimport vertexai\nimport vertex_ray\n\nvertexai.init()\ncluster = vertex_ray.get_ray_cluster(\"\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\")\n\n# Get the resource name.\ncluster_resource_name = cluster.cluster_resource_name\n\n# Create the new worker pools\nnew_worker_node_types = []\nfor worker_node_type in cluster.worker_node_types:\n worker_node_type.node_count = REPLICA_COUNT # new worker pool size\n new_worker_node_types.append(worker_node_type)\n\n# Make update call\nupdated_cluster_resource_name = vertex_ray.update_ray_cluster(\n cluster_resource_name=cluster_resource_name,\n worker_node_types=new_worker_node_types,\n)\n```\n\n### Console\n\n1. In the Google Cloud console, go to the Ray on Vertex AI page.\n\n [Go to the Ray on Vertex AI page](https://console.cloud.google.com/vertex-ai/ray)\n2. From the list of clusters, click the cluster to modify.\n\n3. On the **Cluster details** page, click **Edit cluster**.\n\n4. In the **Edit cluster** pane, select the worker pool to update and then\n modify the replica count.\n\n5. Click **Update**.\n\n Wait a few minutes for your cluster to update. When the update is\n complete, you can see the updated replica count on the **Cluster details**\n page.\n6. Click **Create**."]]