amazon-web-services - EC2 Spot 实例 : How to start tasks, 如何停止它们?

标签 amazon-web-services amazon-ec2

我有一个长时间的批处理作业,我想在 AWS EC2 Spot 实例上运行,以节省资金。但是,我找不到两个看似关键的问题的答案:

  1. 创建新实例后,我需要将代码上传到其中、配置它并运行代码。对于自动和无人值守创建的 Spot 实例,这是如何完成的?

  2. 当实例停止时,我更喜欢有某种类型的通知,以便可以保存状态。 (这并不重要,因为如果突然终止批处理作业会正常运行 - 但最好是干净关闭)。

部署 Spot 实例的标准方法是什么?有没有办法手动设置,把它变成现货实例,然后让它休眠直到现货价格可用?

最佳答案

至于 #1,如果您创建一个 AMI(亚马逊机器镜像),您可以将您想要的所有内容预安装在一个“休眠”镜像上,您可以将其用作您启动的 spot 镜像的基础:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-getting-started.html

对于 #2,当 spot 实例使用 SNS 终止时,您会收到通知:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-autoscaling-notifications.html http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/ASGettingNotifications.html

顺便说一句:您可以收到实例终止的通知,但只有在它终止之后。您无法收到实例即将关闭的通知并优雅地保存状态 - 您需要设计您的解决方案以应对意外关闭。

No matter how high you bid, there is always a risk that your Spot Instance will be interrupted. We strongly recommend against bidding above the On-Demand price or using Spot for applications that cannot tolerate interruptions.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-protect-interruptions.html

关于amazon-web-services - EC2 Spot 实例 : How to start tasks, 如何停止它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25755123/

相关文章:

apache - mod24_ssl 不会读取针对 openssl 验证的证书

amazon-web-services - 在 AWS EC2 VPC 中创建 n 个新实例,然后配置它们

linux - 域重写后的 Nginx 双斜杠

Python3 - 从 json 解析 AWS 实例标签。经历古怪的行为

python - 如何使用 S3 和 Slack 集成编写 AWS lambda 函数

amazon-web-services - 如何通过 CloudFormation 设置 AWS 上 Windows Server 计算机的管理员密码?

amazon-web-services - 当不同用户付费时,管理AWS账户的正确方法是什么?

amazon-ec2 - 504 Gateway Timeout - 两个带有负载均衡器的 EC2 实例

java - 用于 EC2 实例中 session 管理的 Memcached session 管理器