英文:
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 :
- Listen to Fargate Spot termination notices : https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-capacity-providers.html
- When you receive a notice, spin up an on-demand container
- At regular intervals, trigger a Lambda that will check if there are on-demand instances, and if so, try to change by a spot one.
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论