

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

# 计划扩展
<a name="ScheduledScaling"></a>

通过计划扩缩，您可以调整终端节点的配置以适应指定计划的容量需求。计划扩缩会自动调整推理单元的数量，以适应特定时间的使用量激增。您可以对文档分类终端节点和实体识别器终端节点使用计划扩缩。有关计划扩缩的更多信息，请参阅[应用程序自动扩缩中的计划扩缩](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html)。

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

## 设置计划扩缩
<a name="setup-scheduled-scaling"></a>

要为终端节点设置定时扩展，可以使用 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
   ```

1. 创建计划操作。以下示例创建了一个计划操作，以在每天 12:00 UTC 自动调整预配置容量，最小为 2 个推理单元，最大为 5 个推理单元。有关时间表达式和计划扩缩的更多信息，请参阅[计划表达式](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html)。

   对于文档分类端点，请使用以下 AWS CLI 命令：

   ```
   aws application-autoscaling put-scheduled-action \
       --service-namespace comprehend \
       --resource-id arn:aws:comprehend:region:account-id:document-classifier-endpoint/name \
       --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits \
       --scheduled-action-name TestScheduledAction \
       --schedule "cron(0 12 * * ? *)" \
       --scalable-target-action MinCapacity=2,MaxCapacity=5
   ```

   对于实体识别器端点，请使用以下 AWS CLI 命令：

   ```
   aws application-autoscaling put-scheduled-action \
       --service-namespace comprehend \
       --resource-id arn:aws:comprehend:region:account-id:entity-recognizer-endpoint/name \
       --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits \
       --scheduled-action-name TestScheduledAction \
       --schedule "cron(0 12 * * ? *)" \
       --scalable-target-action MinCapacity=2,MaxCapacity=5
   ```

## 删除计划扩缩
<a name="remove-scheduled-scaling"></a>

要删除终端节点的计划扩展，可以使用 AWS CLI 命令删除计划操作，然后取消注册可扩展目标。

**删除计划扩缩**

1. 删除计划操作。以下示例将删除指定的计划操作。

   对于文档分类端点，请使用以下 AWS CLI 命令：

   ```
   aws application-autoscaling delete-scheduled-action \
       --service-namespace comprehend \
       --resource-id arn:aws:comprehend:region:account-id:document-classifier-endpoint/name \
       --scalable-dimension comprehend:document-classifier-endpoint:DesiredInferenceUnits \
       --scheduled-action-name TestScheduledAction
   ```

   对于实体识别器端点，请使用以下 AWS CLI 命令：

   ```
   aws application-autoscaling delete-scheduled-action \
       --service-namespace comprehend \
       --resource-id arn:aws:comprehend:region:account-id:entity-recognizer-endpoint/name \
       --scalable-dimension comprehend:entity-recognizer-endpoint:DesiredInferenceUnits \
       --scheduled-action-name TestScheduledAction
   ```

1. 取消注册可扩展目标。以下示例将注销指定的可扩展目标。

   对于文档分类端点，请使用以下 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
   ```