Signal YCurated AI News
更新于 11/5 20:4061 个信源

用 AWS CDK 编排 SageMaker AI 端点自动扩缩容

企业 AI10/24 00:30AWS 机器学习博客查看原文 ↗
摘要

AWS 官方博客介绍了一种 CDK 方案:通过可复用的 construct 和 CloudFormation 自定义资源,自动完成 SageMaker AI 端点更新前后的扩缩容注销与重新注册,从而避免部署失败或静默丢失扩缩容能力。

核心要点
  • 在 CloudFormation/CDK 中直接修改 SageMaker 实时端点配置(实例类型、实例数、环境变量)会失败,SageMaker 会拒绝更新并报错:The variant(s) "[AllTraffic]" must be deregistered as scalable targets with Application Auto Scaling before they can be removed or have their instance type updated。
  • 先用 AWS CLI 手动注销 scalable target、再只改端点配置:部署虽然成功,但 CloudFormation 因为模板中的扩缩容参数没有变化而不触发注册,端点会在没有任何报错的情况下失去自动扩缩容能力。
  • 先用 AWS CLI 注销、再修改扩缩容参数:CloudFormation 会尝试更新已不存在的 ScalableTarget,报 Resource ... was not found;更严重的是回滚同样失败(UPDATE_ROLLBACK_FAILED),堆栈进入破损状态,需要到控制台人工恢复。
  • 解决思路是用 CDK construct 以三个 CloudFormation 自定义资源替换原生的 AWS::ApplicationAutoScaling::ScalableTarget 与 ScalingPolicy 资源,在端点更新过程中自动编排注销与重新注册。
  • 最终目标是让端点配置变更与扩缩容参数变更合并到单次部署中完成,消除手工在 CLI 与控制台之间来回操作的必要。
原文佐证
  • SageMaker AI requires you to deregister the scalable target before updating the endpoint, but when you deregister it, CloudFormation can’t track the AWS Application Auto Scaling resources.
  • SageMaker AI blocks the endpoint update before CloudFormation reaches the auto scaling resources.
  • This failure is notable because the rollback also fails (UPDATE_ROLLBACK_FAILED), leaving the stack in a broken state that requires manual intervention in the CloudFormation console to recover.
AI 洞察
这类问题暴露了 MLOps 的真实成本结构:瓶颈往往不在模型,而在托管服务的有状态注册机制与声明式基础设施之间的生命周期冲突。SageMaker 的扩缩容依赖 Application Auto Scaling 这一外部注册层,与 CloudFormation 的期望状态模型天然存在矛盾,短期内只能靠自定义资源这种变通方案绕过。对企业而言,推理端点的可运维性应与模型选型同等重要,否则规模上去后会被这类边缘故障持续消耗工程预算。