尽管没有可用的 Spot 实例,AWS ECS 任务仍然 运行

AWS ECS task still running despite no spot instances available

在学习 AWS ECS 时,我创建了一个 Fargate spot 集群并定义了一个服务,上面有一个任务。我可以看到根据我在启动 Fargate 集群时提供的配置自动创建了 EC2 实例的 Spot 请求。

现在我仍然可以访问该应用程序,即使 Spot 请求的历史记录指定 MaxSpotInstanceCountExceeded 自我的实例激活后 1 秒 - 在过去 6 小时内每隔几分钟就会出现错误。

我了解到,如果向我当前使用的实例发送终止通知,Fargate Spot 将尝试启动另一个 Spot 实例,但我不明白我的应用程序怎么可能仍然 运行 因为 Spot 请求处于 error 状态。

  1. Fargate 是否使用与我想象的不同的策略来保留 spot 实例 运行?我没有为我的集群提供任何额外的容量提供程序
  2. 除了第一个问题,使用Fargare spot launch type时是否有可用性保证?
  3. 如何验证我的集群是否确实在使用 Spot 实例?我无法在 AWS 控制台或使用 aws-cli 中识别此信息。我能找到的唯一指标是 spot 请求和我的 ECS 集群使用的公共子网
  4. 为什么我会收到 MaxSpotInstanceCountExceeded 错误?我没有旋转任何其他 spot 实例,所以我很惊讶 Fargate 用尽了 spot 实例限制。或者这个问题可能有不同的原因?
  5. 我能否修改我的 Fargate Spot 集群以扩展所需的 EC2 类型以最大限度地减少 spot 实例不可用性问题?

如果您可以分享更多关于您正在执行的命令或您在何处看到这些信息的数据,将会很有帮助,但只是为了澄清一些事情:

Does Fargate use a different strategy for keeping the spot instances running than I thought? I didn't provide any additional capacity providers to my cluster

Fargate 维护 运行 Fargate Spot 任务的 Spot 容量池。这些池由 Fargate 服务维护,不是您在账户中看到的东西。当客户想要 运行 Spot 任务时,会从池中为 运行 相关任务分配一个实例。

此实例的行为与任何其他 Spot 实例一样,可以随时由 EC2 Spot 回收,并在任务终止和实例返回到 Spot 之前提供 2 分钟警告。当然,如果任务在 EC2 Spot 回收实例之前完成,任务将 运行 照常完成。

In addition to the first question, are there any availability guarantees when using Fargare spot launch type?

不,以任何形式(EC2 或 Fargate)使用 Spot 时都没有可用性保证。 Spot 的全部意义在于,您可以访问其他未使用的计算容量 如果有任何可用的 并且可以随时回收计算容量并发出 2 分钟警告。这就是 Spot 比常规按需使用便宜得多的原因。

Why am I getting the MaxSpotInstanceCountExceeded error? I didn't spin any other spot instances so I'm surprised that Fargate exhausted the spot instance limit. Or maybe there is a different cause to this issue?

你从哪里得到这个错误。如上所述,Fargate 管理用于 运行 所有 Fargate 任务(按需任务和 Spot 类似任务)的计算容量,因此您 运行 Fargate Spot 任务的数量对 EC2 Spot 实例的数量没有影响您可以 运行 在 Fargate 之外。当 运行ning Fargate Spot 任务时,您也不会在您的帐户中看到任何 EC2 Spot 实例,因为相应的 Spot 实例位于 Fargate 服务帐户中。

Can I modify my Fargate Spot cluster to extend the desirable EC2 types to minimize the spot-instance-unavailability issue?

不,您无法影响使用 Fargate 时使用的实例类型。

Fargate Spot 任务由于 Spot 容量不可用而无法启动的情况非常罕见(查看服务指标),如果您可以向我发送相应的任务 ID 和有关您看到此问题的区域的信息,我可以询问团队看看吧。