本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
目標追蹤
透過目標追蹤,您可以根據使用情況調整端點佈建,以符合您的容量需求。推論單元的數目會自動調整,使用的容量在佈建容量的目標百分比內。您可以使用目標追蹤來處理文件分類端點和實體辨識器端點的暫時使用激增。如需詳細資訊,請參閱 Application Auto Scaling 的目標追蹤擴展政策。
注意
下列範例會針對 Unix、Linux 和 macOS 進行格式化。用於 Windows 時,請以插入號 (^) 取代每一行結尾處的 Unix 接續字元斜線 (\)。
設定目標追蹤
若要為端點設定目標追蹤,您可以使用 AWS CLI 命令註冊可擴展的目標,然後建立擴展政策。可擴展目標將推論單元定義為用於調整端點佈建的資源,而擴展政策則定義了控制佈建容量 auto 調整的指標。
若要設定目標追蹤
-
登錄可擴展的目標。下列範例會註冊一個可擴充的目標,以調整端點佈建,其容量下限為 1 個推論單元,最大容量為 2 個推論單元。
對於文件分類端點,請使用下列 AWS CLI 指令:
aws application-autoscaling register-scalable-target \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:document-classifier-endpoint/name
\ --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits \ --min-capacity 1 \ --max-capacity 2對於實體識別器端點,請使用以下 AWS CLI 命令:
aws application-autoscaling register-scalable-target \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:entity-recognizer-endpoint/name
\ --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits \ --min-capacity 1 \ --max-capacity 2 -
若要驗證可擴充目標的註冊,請使用下列 AWS CLI 命令:
aws application-autoscaling describe-scalable-targets \ --service-namespace comprehend \ --resource-id
endpoint ARN
-
為擴展政策建立目標追蹤組態,並將組態儲存在名為的檔案中
config.json
。以下是自動調整推論單元數目的目標追蹤組態範例,使用的容量永遠是佈建容量的 70%。{ "TargetValue": 70, "PredefinedMetricSpecification": { "PredefinedMetricType": "ComprehendInferenceUtilization" } }
-
建立擴展政策。下列範例會根據
config.json
檔案中定義的目標追蹤組態建立資源調整政策。對於文件分類端點,請使用下列 AWS CLI 指令:
aws application-autoscaling put-scaling-policy \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:document-classifier-endpoint/name
\ --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits \ --policy-nameTestPolicy
\ --policy-type TargetTrackingScaling \ --target-tracking-scaling-policy-configuration file://config.json對於實體識別器端點,請使用以下 AWS CLI 命令:
aws application-autoscaling put-scaling-policy \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:entity-recognizer-endpoint/name
\ --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits \ --policy-nameTestPolicy
\ --policy-type TargetTrackingScaling \ --target-tracking-scaling-policy-configuration file://config.json
移除目標追蹤
若要移除端點的目標追蹤,您可以使用 AWS CLI 命令刪除擴展政策,然後取消註冊可擴展目標。
若要移除目標追蹤
-
刪除資源調度政策。下列範例會刪除指定的資源調整政策。
對於文件分類端點,請使用下列 AWS CLI 指令:
aws application-autoscaling delete-scaling-policy \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:document-classifier-endpoint/name
\ --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits \ --policy-nameTestPolicy
\對於實體識別器端點,請使用以下 AWS CLI 命令:
aws application-autoscaling delete-scaling-policy \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:entity-recognizer-endpoint/name
\ --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits \ --policy-nameTestPolicy
-
取消註冊可擴展的目標。下列範例會取消註冊指定的可縮放目標。
對於文件分類端點,請使用下列 AWS CLI 指令:
aws application-autoscaling deregister-scalable-target \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:document-classifier-endpoint/name
\ --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits對於實體識別器端點,請使用以下 AWS CLI 命令:
aws application-autoscaling deregister-scalable-target \ --service-namespace comprehend \ --resource-id arn:aws:comprehend:
region
:account-id
:entity-recognizer-endpoint/name
\ --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits