目标跟踪 - Amazon Comprehend

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

目标跟踪

通过目标跟踪,您可以根据使用情况调整终端节点配置,以满足您的容量需求。推理单元的数量会自动调整,使已利用容量保持在预配置容量的目标百分比之内。您可以使用目标跟踪来适应文档分类终端节点和实体识别器终端节点的临时使用激增。有关更多信息,请参阅 Application Auto Scaling 的目标跟踪扩缩策略

注意

以下示例的格式适用于 Unix、Linux 和 macOS。对于 Windows,请将每行末尾的反斜杠 (\) Unix 行继续符替换为脱字号 (^)。

设置目标跟踪

要为终端节点设置目标跟踪,您可以使用 AWS CLI 命令注册可扩展目标,然后创建扩缩策略。可扩展目标将推理单元定义为用于调整终端节点配置的资源,扩缩策略定义了控制预配置容量自动扩缩的指标。

设置目标跟踪
  1. 注册可扩展目标。以下示例注册了一个可扩展的目标,以调整终端节点配置,其最小容量为 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
  2. 要验证可扩展目标的注册,请使用以下 AWS CLI 命令:

    aws application-autoscaling describe-scalable-targets \ --service-namespace comprehend \ --resource-id endpoint ARN
  3. 为扩缩策略创建目标跟踪配置,并将该配置保存在名为 config.json 的文件中。以下是目标跟踪配置的示例,该配置会自动调整推理单元的数量,使已利用容量始终为预配置容量的 70%。

    { "TargetValue": 70, "PredefinedMetricSpecification": { "PredefinedMetricType": "ComprehendInferenceUtilization" } }
  4. 创建扩缩策略。以下示例根据 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-name TestPolicy \ --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-name TestPolicy \ --policy-type TargetTrackingScaling \ --target-tracking-scaling-policy-configuration file://config.json

正在删除目标跟踪

要为终端节点删除目标跟踪,您可以使用 AWS CLI 命令删除扩缩策略,然后注销可扩展目标。

删除目标跟踪
  1. 删除扩缩策略。以下示例删除了指定扩缩策略。

    对于文档分类终端节点,请使用 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-name TestPolicy \

    对于实体识别器终端节点,请使用以下 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-name TestPolicy
  2. 取消注册可扩展目标。以下示例将注销指定的可扩展目标。

    对于文档分类终端节点,请使用 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