2. AWS Community
Key Takeaway
- What is EC2 Spot Instances and how it works
- The true cost of Spot Instances
- How we could programmatically get the max-price value
8. AWS Community
2 minute termination notice. EC2 meta-data and
EventBridge
More info: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-instance-termination-
notices.html
9. AWS Community
The Fault Injection Simulator can simulate
termination notices
More info: https://aws.amazon.com/fis/
14. Allocation strategies for Spot Instances
More info: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-fleet-allocation-
strategy.html
15. AWS Community
Allocation strategies for Spot Instances
- price-capacity-optimized !!!
- capacity-optimized
- lowest-price
More info: https://aws.amazon.com/blogs/compute/introducing-price-capacity-optimized-
allocation-strategy-for-ec2-spot-instances/
16. Resilience with Capacity rebalance.
Get new EC2 in advance.
More info: https://ec2spotworkshops.com/ec2-auto-scaling-with-multiple-instance-types-and-
purchase-options/spot_resilience.html
17. AWS Community
EC2 Autoscaling Capacity rebalance
More info: https://github.com/awslabs/ec2-spot-labs/tree/master/ec2-spot-interruption-handler
25. Spot Max Price
More info: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#using-
spot-instances-request (step 10 in new console example)
26. What will happen if the Spot Max Price
is not specified?
More info: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#using-
spot-instances-request (step 10 in new console example)
28. AWS Community
AWS CLI: aws ec2 describe-spot-price-history
More info: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-
spot-price-history.html
29. AWS Community
AWS API: EC2 DescribeSpotPriceHistory
More info:
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSpotPriceHistory.html
31. AWS Community
Initial data
AZ Type r5.2xlarge r5d.2xlarge r5a.2xlarge
eu-central-1a 0.20 0.20 0.20
eu-central-1b 0.20 0.15 0.10
eu-central-1c 0.20 0.30 0.25
*These prices are not real prices for EC2 Spot Instance
32. AWS Community
Example: All Instance Types in all AZs with
increased reliability.
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
сustom_price_modifier = 1.1
}
output "spot_price_current_max_mod" {
value = module.ec2_spot_price.spot_price_current_max_mod
}
Result: 0.33
33. AWS Community
Example: Cheapest as possible
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
}
output "spot_price_current_max_mod" {
value = module.ec2_spot_price.spot_price_current_min
}
Result: 0.10