简体   繁体   中英

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. For example, the desired number of instances is 3 and we have 4 AZ where they might be placed. 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.

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. 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.

If you wish to avoid spot instances losing capacity, then a good strategy is:

  • 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
  • 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 can only have one active Launch Configuration or Launch Template at any one time. Therefore, it cannot automatically switch between on-demand and spot instances.

You might want to look into Launching an EC2 Fleet , which can automatically launch a range of different instance types across multiple Availability Zones. There are also some recommended EC2 Fleet Configuration Strategies .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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