HyperPod 추론 모델 배포를 위한 Autoscaling 정책 - Amazon SageMaker AI

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

HyperPod 추론 모델 배포를 위한 Autoscaling 정책

다음 정보는 Amazon SageMaker HyperPod 추론 모델 배포에 오토 스케일링 정책을 구현하기 위한 실제 예제와 구성을 제공합니다.

autoScalingSpec 배포 YAML 파일에 내장된를 사용하여 자동 조정을 구성하는 방법과 고급 조정 시나리오를 위한 독립 실행형 KEDA ScaledObject 구성을 생성하는 방법을 알아봅니다. 이 예제에서는 CloudWatch 지표, Amazon SQS 대기열 길이, Prometheus 쿼리, CPU 및 메모리와 같은 리소스 사용률 지표를 기반으로 하는 조정 트리거를 다룹니다.

배포 YAML에서 autoScalingSpec 사용

Amazon SageMaker HyperPod 추론 운영자는 CloudWatch 및 Amazon Managed Prometheus(AMP)의 지표를 사용하여 모델 배포를 위한 기본 Auto Scaling 기능을 제공합니다. 다음 배포 YAML 예제에는 모델 배포 규모 조정을 위한 구성 값을 정의하는 autoScalingSpec 섹션이 포함되어 있습니다.

apiVersion: inference.sagemaker.aws.amazon.com/v1alpha1 kind: JumpStartModel metadata: name: deepseek-sample624 namespace: ns-team-a spec: sageMakerEndpoint: name: deepsek7bsme624 model: modelHubName: SageMakerPublicHub modelId: deepseek-llm-r1-distill-qwen-1-5b modelVersion: 2.0.4 server: instanceType: ml.g5.8xlarge metrics: enabled: true environmentVariables: - name: SAMPLE_ENV_VAR value: "sample_value" maxDeployTimeInSeconds: 1800 tlsConfig: tlsCertificateOutputS3Uri: "s3://{USER}-tls-bucket-{REGION}/certificates" autoScalingSpec: minReplicaCount: 0 maxReplicaCount: 5 pollingInterval: 15 initialCooldownPeriod: 60 cooldownPeriod: 120 scaleDownStabilizationTime: 60 scaleUpStabilizationTime: 0 cloudWatchTrigger: name: "SageMaker-Invocations" namespace: "AWS/SageMaker" useCachedMetrics: false metricName: "Invocations" targetValue: 10.5 activationTargetValue: 5.0 minValue: 0.0 metricCollectionStartTime: 300 metricCollectionPeriod: 30 metricStat: "Sum" metricType: "Average" dimensions: - name: "EndpointName" value: "deepsek7bsme624" - name: "VariantName" value: "AllTraffic" prometheusTrigger: name: "Prometheus-Trigger" useCachedMetrics: false serverAddress: http://<prometheus-host>:9090 query: sum(rate(http_requests_total{deployment="my-deployment"}[2m])) targetValue: 10.0 activationTargetValue: 5.0 namespace: "namespace" customHeaders: "X-Client-Id=cid" metricType: "Value"

배포 YAML에 사용되는 필드 설명

minReplicaCount (선택 사항, 정수)

클러스터에서 유지할 최소 모델 배포 복제본 수를 지정합니다. 스케일 다운 이벤트 중에 배포는이 최소 포드 수로 스케일 다운됩니다. 0보다 크거나 같아야 합니다. 기본값: 1.

maxReplicaCount (선택 사항, 정수)

클러스터에서 유지할 최대 모델 배포 복제본 수를 지정합니다. 보다 크거나 같아야 합니다minReplicaCount. 스케일 업 이벤트 중에 배포는이 최대 포드 수까지 스케일 업됩니다. 기본값: 5.

pollingInterval (선택 사항, 정수)

지표 쿼리를 위한 초 단위 시간 간격입니다. 최소값: 0 기본값: 30초.

cooldownPeriod (선택 사항, 정수)

축소 이벤트 중에 포드를 1개에서 0개로 축소하기 전에 대기하는 초 단위 시간 간격입니다. minReplicaCount가 0으로 설정된 경우에만 적용됩니다. 최소값: 0 기본값: 300초.

initialCooldownPeriod (선택 사항, 정수)

초기 배포 중에 포드를 1개에서 0개로 스케일 다운하기 전에 대기하는 초 단위 시간 간격입니다. minReplicaCount가 0으로 설정된 경우에만 적용됩니다. 최소값: 0 기본값: 300초.

scaleDownStabilizationTime (선택 사항, 정수)

축소 트리거가 활성화된 후 축소가 발생하기 전에 초 단위의 안정화 기간입니다. 최소값: 0 기본값: 300초.

scaleUpStabilizationTime (선택 사항, 정수)

스케일 업 트리거가 활성화된 후 스케일 업이 발생하기 전에 초 단위의 안정화 기간입니다. 최소값: 0 기본값: 0초.

cloudWatchTrigger

Auto Scaling 결정에 사용되는 CloudWatch 지표의 트리거 구성입니다. 에서 사용할 수 있는 필드는 cloudWatchTrigger다음과 같습니다.

  • name (선택 사항, 문자열) - CloudWatch 트리거의 이름입니다. 제공되지 않은 경우는 기본 형식인 <model-deployment-name>-scaled-object-cloudwatch-trigger를 사용합니다.

  • useCachedMetrics (선택 사항, 부울) - KEDA에서 쿼리한 지표를 캐싱할지 여부를 결정합니다. KEDA는 pollingInterval을 사용하여 지표를 쿼리하는 반면, Horizontal Pod Autoscaler(HPA)는 KEDA에서 15초마다 지표를 요청합니다. true로 설정하면 쿼리된 지표가 캐시되고 HPA 요청을 처리하는 데 사용됩니다. 기본값: true.

  • namespace (필수, 문자열) - 쿼리할 지표의 CloudWatch 네임스페이스입니다.

  • metricName (필수, 문자열) - CloudWatch 지표의 이름입니다.

  • dimensions (선택 사항, 목록) - 지표의 차원 목록입니다. 각 차원에는 이름(차원 이름 - 문자열)과 값(차원 값 - 문자열)이 포함됩니다.

  • targetValue (필수, 부동 소수점) - 자동 크기 조정 결정에 사용되는 CloudWatch 지표의 대상 값입니다.

  • activationTargetValue (선택 사항, 부동 소수점) - 포드를 0개에서 1개로 조정할 때 사용되는 CloudWatch 지표의 대상 값입니다. minReplicaCount가 0으로 설정된 경우에만 적용됩니다. 기본값: 0.

  • minValue (선택 사항, 부동 소수점) - CloudWatch 쿼리가 데이터를 반환하지 않을 때 사용할 값입니다. 기본값: 0.

  • metricCollectionStartTime (선택 사항, 정수) - 지표 쿼리의 시작 시간으로, T-metricCollectionStartTime으로 계산됩니다. metricCollectionPeriod보다 크거나 같아야 합니다. 기본값: 300초.

  • metricCollectionPeriod (선택 사항, 정수) - 지표 쿼리의 초 단위 기간입니다. CloudWatch 지원 값(1, 5, 10, 30 또는 60의 배수)이어야 합니다. 기본값: 300초.

  • metricStat (선택 사항, 문자열) - CloudWatch 쿼리의 통계 유형입니다. 기본값: Average.

  • metricType (선택 사항, 문자열) - 지표가 조정 계산에 사용되는 방법을 정의합니다. 기본값: Average. 허용된 값: Average, Value

    • 평균: 원하는 복제본 = ceil(지표 값) / (targetValue)

    • : 원하는 복제본 = (현재 복제본) × ceil(지표 값) / (targetValue)

prometheusTrigger

오토 스케일링 결정에 사용되는 Amazon Managed Prometheus(AMP) 지표의 트리거 구성입니다. 에서 사용할 수 있는 필드는 prometheusTrigger다음과 같습니다.

  • name (선택 사항, 문자열) - CloudWatch 트리거의 이름입니다. 제공되지 않은 경우는 기본 형식인 <model-deployment-name>-scaled-object-cloudwatch-trigger를 사용합니다.

  • useCachedMetrics (선택 사항, 부울) - KEDA에서 쿼리한 지표를 캐싱할지 여부를 결정합니다. KEDA는 pollingInterval을 사용하여 지표를 쿼리하는 반면, Horizontal Pod Autoscaler(HPA)는 KEDA에서 15초마다 지표를 요청합니다. true로 설정하면 쿼리된 지표가 캐시되고 HPA 요청을 처리하는 데 사용됩니다. 기본값: true.

  • serverAddress (필수, 문자열) - AMP 서버의 주소입니다. <https://aps-workspaces.<region>.amazonaws.com/workspaces/<workspace_id> 형식을 사용해야 합니다.

  • query (필수, 문자열) - 지표에 사용되는 PromQL 쿼리입니다. 스칼라 값을 반환해야 합니다.

  • targetValue (필수, 부동 소수점) - 자동 크기 조정 결정에 사용되는 CloudWatch 지표의 대상 값입니다.

  • activationTargetValue (선택 사항, 부동 소수점) - 포드를 0개에서 1개로 조정할 때 사용되는 CloudWatch 지표의 대상 값입니다. minReplicaCount가 0으로 설정된 경우에만 적용됩니다. 기본값: 0.

  • namespace (선택 사항, 문자열) - 네임스페이스 쿼리에 사용할 네임스페이스입니다. 기본값: 빈 문자열("").

  • customHeaders (선택 사항, 문자열) - Prometheus 엔드포인트를 쿼리할 때 포함할 사용자 지정 헤더입니다. 기본값: 빈 문자열("").

  • metricType (선택 사항, 문자열) - 지표가 조정 계산에 사용되는 방법을 정의합니다. 기본값: Average. 허용된 값: Average, Value

    • 평균: 원하는 복제본 = ceil(지표 값) / (targetValue)

    • : 원하는 복제본 = (현재 복제본) × ceil(지표 값) / (targetValue)

kubectl을 통해 KEDA ScaledObject yaml 정의 사용

배포 YAML의 autoScalingSpec 섹션을 통해 자동 크기 조정을 구성하는 것 외에도 kubectl을 사용하여 독립 실행형 KEDA ScaledObject YAML 정의를 생성하고 적용할 수 있습니다.

이 접근 방식은 복잡한 조정 시나리오에 대한 유연성을 높이고 모델 배포와 독립적으로 Auto Scaling 정책을 관리할 수 있습니다. KEDA ScaledObject 구성은 CloudWatch 지표, Amazon SQS 대기열 길이, Prometheus 쿼리, CPU 및 메모리 사용률과 같은 리소스 기반 지표를 포함한 다양한 조정 트리거를 지원합니다. ScaledObject 사양의 scaleTargetRef 섹션에서 배포 이름을 참조하여 이러한 구성을 기존 모델 배포에 적용할 수 있습니다.

참고

HyperPod 추론 연산자 설치 중에 제공된 keda 연산자 역할에 조정된 객체 트리거에 정의된 지표를 쿼리할 수 있는 적절한 권한이 있는지 확인합니다.

CloudWatch 지표

다음 KEDA yaml 정책은 CloudWatch 지표를 트리거로 사용하여 kubernetes 배포에서 Auto Scaling을 수행합니다. 이 정책은 Sagemaker 엔드포인트에 대한 호출 수를 쿼리하고 배포 포드 수를 조정합니다. aws-cloudwatch 트리거에 대해 KEDA에서 지원하는 파라미터의 전체 목록은 https://keda.sh/docs/2.17/scalers/aws-cloudwatch/ 확인할 수 있습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 1 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 triggers: - type: aws-cloudwatch metadata: namespace: AWS/SageMaker metricName: Invocations targetMetricValue: "1" minMetricValue: "1" awsRegion: "us-west-2" dimensionName: EndpointName;VariantName dimensionValue: $ENDPOINT_NAME;$VARIANT_NAME metricStatPeriod: "30" # seconds metricStat: "Sum" identityOwner: operator

Amazon SQS 지표

다음 KEDA yaml 정책은 Amazon SQS 지표를 트리거로 사용하여 kubernetes 배포에서 자동 크기 조정을 수행합니다. 이 정책은 Sagemaker 엔드포인트에 대한 호출 수를 쿼리하고 배포 포드 수를 조정합니다. aws-cloudwatch 트리거에 대해 KEDA에서 지원하는 파라미터의 전체 목록은 https://keda.sh/docs/2.17/scalers/aws-sqs/ 확인할 수 있습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 1 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 triggers: - type: aws-sqs-queue metadata: queueURL: https://sqs.eu-west-1.amazonaws.com/account_id/QueueName queueLength: "5" # Default: "5" awsRegion: "us-west-1" scaleOnInFlight: true identityOwner: operator

Prometheus 지표

다음 KEDA yaml 정책은 Prometheus 지표를 트리거로 사용하여 kubernetes 배포에서 자동 크기 조정을 수행합니다. 이 정책은 Sagemaker 엔드포인트에 대한 호출 수를 쿼리하고 배포 포드 수를 조정합니다. aws-cloudwatch 트리거에 대해 KEDA에서 지원하는 파라미터의 전체 목록은 https://keda.sh/docs/2.17/scalers/prometheus/ 확인할 수 있습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 1 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 triggers: - type: prometheus metadata: serverAddress: http://<prometheus-host>:9090 query: avg(rate(http_requests_total{deployment="$DEPLOYMENT_NAME"}[2m])) # Note: query must return a vector/scalar single element response threshold: '100.50' namespace: example-namespace # for namespaced queries, eg. Thanos customHeaders: X-Client-Id=cid,X-Tenant-Id=tid,X-Organization-Id=oid # Optional. Custom headers to include in query. In case of auth header, use the custom authentication or relevant authModes. unsafeSsl: "false" # Default is `false`, Used for skipping certificate check when having self-signed certs for Prometheus endpoint timeout: 1000 # Custom timeout for the HTTP client used in this scaler identityOwner: operator

CPU 지표

다음 KEDA yaml 정책은 cpu 지표를 트리거로 사용하여 kubernetes 배포에서 Auto Scaling을 수행합니다. 이 정책은 Sagemaker 엔드포인트에 대한 호출 수를 쿼리하고 배포 포드 수를 조정합니다. aws-cloudwatch 트리거에 대해 KEDA에서 지원하는 파라미터의 전체 목록은 https://keda.sh/docs/2.17/scalers/prometheus/ 확인할 수 있습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 1 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 triggers: - type: cpu metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue' metadata: value: "60" containerName: "" # Optional. You can use this to target a specific container

메모리 지표

다음 KEDA yaml 정책은 Prometheus 지표 쿼리를 트리거로 사용하여 kubernetes 배포에서 자동 크기 조정을 수행합니다. 이 정책은 Sagemaker 엔드포인트에 대한 호출 수를 쿼리하고 배포 포드 수를 조정합니다. aws-cloudwatch 트리거에 대해 KEDA에서 지원하는 파라미터의 전체 목록은 https://keda.sh/docs/2.17/scalers/prometheus/ 확인할 수 있습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 1 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 triggers: - type: memory metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue' metadata: value: "60" containerName: "" # Optional. You can use this to target a specific container in a pod

포드를 0개로 축소하기 위한 샘플 Prometheus 정책

다음 KEDA yaml 정책은 prometheus 지표 쿼리를 트리거로 사용하여 kubernetes 배포에서 자동 크기 조정을 수행합니다. 이 정책은 KEDA가 배포를 0개의 포드로 축소할 수 있는 0minReplicaCount의를 사용합니다. minReplicaCount가 0으로 설정된 경우 포드가 0으로 축소된 후 첫 번째 포드를 가져오려면 활성화 기준을 제공해야 합니다. Prometheus 트리거의 경우이 값은에서 제공합니다activationThreshold. SQS 대기열의 경우에서 가져옵니다activationQueueLength.

참고

0minReplicaCount을 사용하는 동안 활성화가 포드에서 생성되는 지표에 의존하지 않는지 확인합니다. 포드가 0으로 축소되면 해당 지표가 생성되지 않고 포드가 다시 확장되지 않습니다.

apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: invocations-scaledobject # name of the scaled object that will be created by this namespace: ns-team-a # namespace that this scaled object targets spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: $DEPLOYMENT_NAME # name of the model deployment minReplicaCount: 0 # minimum number of pods to be maintained maxReplicaCount: 4 # maximum number of pods to scale to pollingInterval: 10 cooldownPeriod: 30 initialCooldownPeriod: 180 # time before scaling down the pods after initial deployment triggers: - type: prometheus metadata: serverAddress: http://<prometheus-host>:9090 query: sum(rate(http_requests_total{deployment="my-deployment"}[2m])) # Note: query must return a vector/scalar single element response threshold: '100.50' activationThreshold: '5.5' # Required if minReplicaCount is 0 for initial scaling namespace: example-namespace timeout: 1000 identityOwner: operator
참고

CPU 또는 메모리가 아닌 추가 스케일러를 하나 이상 정의한 경우에만 CPU 및 메모리 트리거를 0으로 조정할 수 있습니다(예: SQS + CPU 또는 Prometheus + CPU).