

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

# 更新使用自动扩缩的端点
<a name="endpoint-scaling-update"></a>

更新端点时，应用程序自动扩缩会检查该端点上是否有任何模型是自动扩缩的目标。如果更新会改变作为自动扩缩目标的任何模型的实例类型，则更新失败。

在中 AWS 管理控制台，您会看到一条警告，提示您必须先从 auto Scaling 中取消注册模型，然后才能对其进行更新。如果您试图通过调用[UpdateEndpoint](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateEndpoint.html) API 来更新终端节点，则调用将失败。在更新终端节点之前，请删除为其配置的所有扩展策略，并通过调用 App [DeregisterScalableTarget](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_DeregisterScalableTarget.html)lication Auto Scaling API 操作将该变体取消注册为可扩展目标。更新端点后，您可以将更新后的变体注册为可扩展目标，并附加扩展策略。

有一个例外。如果您更改配置为自动缩放的变体的模型，Amazon A SageMaker I auto scaling 将允许更新。这是因为更改模型对性能的影响通常不足以改变扩展行为。如果您确实要为配置为自动扩缩的变体更新模型，请确保对模型的更改不会对性能和扩展行为造成重大影响。

更新应用了 auto Scaling 的 SageMaker AI 终端节点时，请完成以下步骤：

**更新已应用自动扩缩功能的端点**

1. 通过调[DeregisterScalableTarget](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_DeregisterScalableTarget.html)用取消将终端节点注册为可扩展目标。

1. 由于在更新操作过程中自动扩缩会被阻止（或者如果您在上一步中关闭了自动扩缩），您可能需要采取额外的预防措施，在更新期间增加端点的实例数量。为此，请通过调用 [UpdateEndpointWeightsAndCapacities](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateEndpointWeightsAndCapacities.html)，为该终端节点上托管的生产变体增加实例数量。

1. 重复调用 [ DescribeEndpoint](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpoint.html)，直到响应的 `EndpointStatus` 字段的值为 `InService`。

1. 调用 [ DescribeEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html) 来获取当前终端节点配置值。

1. 通过调用 [ CreateEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpointConfig.html) 创建新的终端节点配置。对于要保留现有实例计数或权重的生产变体，请使用在前一步中调用 [ DescribeEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html) 所得到的响应中的相同变体名称。对于所有其他值，请使用在上一步骤中调用 [ DescribeEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html) 时作为响应获取的值。

1. 通过调用 [ UpdateEndpoint](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateEndpoint.html) 更新终端节点。指定在上一步中创建的终端节点配置作为 `EndpointConfig` 字段。如果要保留变体属性（如实例计数或权重），请将 `RetainAllVariantProperties` 参数的值设置为 `True`。这会指定具有相同名称的生产变体将使用从调用 `DescribeEndpoint` 得到的响应中的最新 `DesiredInstanceCount` 进行更新，而不考虑新 `EndpointConfig` 中 `InitialInstanceCount` 字段的值。

1. （可选）通过调用[RegisterScalableTarget](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)和[PutScalingPolicy](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScalingPolicy.html)来重新激活 auto Scaling。

**注意**  
只有在使用以下更改更新终端节点时，才需要步骤 1 和 7：  
更改已配置自动扩缩的生产变体的实例类型
删除已配置自动扩缩功能的生产变体。