简体   繁体   English

AWS 自动扩展和 Spot 实例

[英]AWS autoscaling and spot instances

I am working on my small project and using mix of spot and on-demand instances.我正在处理我的小项目并混合使用现货和按需实例。 I need to setup autoscaling to launch spot instances in different AZ only.我需要设置自动缩放以仅在不同的可用区中启动 Spot 实例。 For example, the desired number of instances is 3 and we have 4 AZ where they might be placed.例如,所需的实例数是 3,我们有 4 个可用区来放置它们。 Autoscaling tries to place the instances in different AZ but if it fails, it launches them in the same AZ, which is something I don't want. Autoscaling 尝试将实例放在不同的 AZ 中,但如果失败,它会在同一个 AZ 中启动它们,这是我不想要的。

I'd like to use another logic.我想使用另一种逻辑。 If Autoscaling is not able to place all spot instances in different AZ, it starts launching on-demand ones instead.如果 Autoscaling 无法将所有 Spot 实例放置在不同的 AZ 中,它将开始启动按需实例。 Is it possible to setup with tools that we have?是否可以使用我们拥有的工具进行设置?

I want to avoid the situation where a few spot instances will end up in the same AZ because if the AZ capacity goes down, amazon terminates them quickly and I will not have any time to relaunch them somewhere else.我想避免几个 Spot 实例最终出现在同一个可用区的情况,因为如果可用区容量下降,亚马逊会迅速终止它们,我将没有时间在其他地方重新启动它们。

If you wish to avoid spot instances losing capacity, then a good strategy is:如果您希望避免 Spot 实例失去容量,那么一个好的策略是:

  • Use a mix of Instance Types: If spot instances of one type are terminated due to low capacity, then it is unlikely that other instance types will be impacted at the same time混合使用实例类型:如果一种类型的 Spot 实例因容量不足而终止,那么其他实例类型不太可能同时受到影响
  • Spread the instances across Availability Zones (as you are doing), since capacity pools are separate in each AZ跨可用区分布实例(正如您所做的那样),因为容量池在每个可用区中都是独立的

Auto Scaling will automatically attempt to balance the number of EC2 instances across Availability Zones. Auto Scaling将自动尝试平衡可用区之间的 EC2 实例数量。 Auto Scaling can only have one active Launch Configuration or Launch Template at any one time. Auto Scaling 在任何时候只能有一个活动的启动配置或启动模板。 Therefore, it cannot automatically switch between on-demand and spot instances.因此,它无法在按需实例和 Spot 实例之间自动切换。

You might want to look into Launching an EC2 Fleet , which can automatically launch a range of different instance types across multiple Availability Zones.您可能想要研究Launching an EC2 Fleet ,它可以跨多个可用区自动启动一系列不同的实例类型。 There are also some recommended EC2 Fleet Configuration Strategies .还有一些推荐的EC2 Fleet Configuration Strategies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM