Is it possible to use ECS spot till it's unavailable and switch to On demand and back?

huangapple go评论61阅读模式
英文:

Is it possible to use ECS spot till it's unavailable and switch to On demand and back?

问题

I'm reading about the ECS spot (Fargate) and the capacity provider. In the examples, I see they always create an on-demand capacity provider e.g. 1 running task, and then a spot provider with a variable amount of tasks.

Is it possible to run one ECS task on spot --> When it goes down, use an on-demand instance till spot is back available and switch back? Or do I not understand the concept properly?

英文:

I'm reading about the ECS spot (Fargate) and the capacity provider. In the examples, I see they always create an on-demand capacity provider e.g. 1 running task, and then a spot provider with a variable amount of tasks.

Is it possible to run one ECS task on spot --> When it goes down, use an on-demand instance till spot is back available and switch back? Or do I not understand the concept properly?

答案1

得分: 1

Spot实例不应该按照您描述的方式使用。它们非常适合容错性的作业,或者与按需实例一起运行,以确保您的服务不会中断,同时减轻主要按需实例(或Fargate容器)的一些压力。

话虽如此,如果您的服务真的不那么重要,而且可以接受一些不可用性,您可以尝试通过CloudWatch Events定期触发Lambda函数来实现。

以下是一些步骤:

  • 监听Fargate Spot终止通知:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-capacity-providers.html
  • 当您收到通知时,启动一个按需容器
  • 定期触发一个Lambda函数,检查是否存在按需实例,如果有的话,尝试切换为Spot实例。

这只是用来学习和尝试的方式,但不建议在生产环境中使用。

祝好运!

英文:

Spot instances are not meant to be used in the way you described. They are really useful for fault tolerant jobs, or to run along side on-demand instances, to ensure that your service does not go down, while removing some pressure off of the main on-demand instances (or Fargate containers)

That being said, if your service is really not that important, and you're ready to have some unavailability, you can try to hack together some Lambda function, that you can trigger at fixed interval using CloudWatch Events.

In a few steps :

This is really just if you want to play and learn, but it's not a recommended approach. I would never do this in production.

Cheers

huangapple
  • 本文由 发表于 2023年4月6日 21:25:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75950074.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定