1 Answer
- Newest
- Most votes
- Most comments
0
Based on your snippit and tags on this question, I assume you're talking about launching Spot instances in an ASG?
Currently there's no way to do what you're asking. The ASG will always first try to balance work across all available AZs. However, the AutoScaling team is always working on new options to meet usecases that aren't currently possible, so I've passed on this feedback to them for future feature decisions.
Currently you have 3 options
- Leave it as-is, and let ASG launch across all the AZs
- Lambda functions, as you suggested (periodically checking prices and swapping the single AZ for the ASG) - note that this is much more likely to have availability issues from launch failures
- Create 2 ASGs; 1 in your preferred AZ and another with all the other regions AZs enabled in it. Set the scaling metrics such that the "Primary" ASG scales first. This could lead to a bit of oscillation/churn between ASGs, especially if its a smaller environment and/or the metric is spiky
- directly launch capacity via
aws ec2 create-fleet
instead of using an ASG (but, you'll lose out on all the other ASG features if you do this)
Remember that Spot prices can and will change over time, so even if that 1 AZ has been cheaper in the short/medium term doesn't mean it'll always be that way, or that it'll have enough Spot capacity to consistently meet your needs
Relevant content
- asked 6 months ago
- AWS OFFICIALUpdated 10 months ago
Hi Shahad, your analysis is correct, and I forgot to mention it's an ASG with only 1 instance. It's serving as capacity provider for ECS. I don't understand the suggested "2 ASGs" architecture, would this work with ECS?. Also I'm not sure EC2 Fleet will work as an ECS Capacity Provider. So I'll have to create a Lambda to change the target type and monitor for availability issues. I have been watching this region and for the past several months the prices have been the same, with one AZ consistently cheaper. If I wanted to have availability guarantees, I would use one of the other spot strategy options or even an On-demand or Reserved instance. I'm quite disappointed that LOWEST_PRICE does not mean LOWEST_PRICE -- this would be the best feedback you can provide to the responsible team.
Ahh, I assumed this was a larger environment. The 2 ASGs option would be for if you had more instances (would work best with at least a couple dozen). In general it would still work with ECS, but likely not with a single instance type. And you're correct, Capacity Providers specifically are designed to work with an ASG. I've passed on your feedback that you'd like it to be "Lowest price for the region" vs "Lowest price for the AZ the ASG selects". Thank you very much for taking the time to provide these details around your usecase