Spot Instances are the cheapest available resource on AWS, but they are not guaranteed to be available and may become unavailable while the instance is running. So spot instances are effective at decreasing the overall cost by as much as 90% compared to On-demand, but are not suitable for required computer services. The following are specification of Spot Instances.
1. Can reduce cost up to 90% compared to On-demand
2. Hourly spot prices for service change continuously
3. You can set a max spot price you are willing to pay
a. If the max spot price you defined is exceeded, you have a 2 minute grace period
b. You must decide to either stop or terminate your instance
4. You have an option for a Spot Block
a. Guarantees no interruptions from 1 to 6 hours of time
b. Spot Blocks were supported after 31 Dec 2022
Placing Spot Requests – Request for spot resources, that contains:
1. Max Price
2. Desired number of instances
3. Launch specifications
4. Request type: one-time or persistent
a. one-time is removed once request is complete
b. persistent will become request again once it is stopped or terminated
5. Valid start time and stop time
Spot Requests Specifics:
1. Request is made and AWS attempts to fill request.
2. You can only cancel while in open, active, or disabled states.
3. You have to cancel spot request and terminate any instances created by the request. In this order
4. Canceling spot requests does not terminate running instances.
Spot Fleet – is a set of spot instance + optional on-demand instances.
1. Spot Fleet will try to fill the target resources with the price set by customer.
2. AWS will take available pools of varing instance type, OS, and Availability Zones to attempt to meet request.
3. You can have multiple launch pools the fleet can choose from.
4. Spot fleet stops launching instances when capacity or max price is reached.
5. Spot Fleets allow us to automatically request spot instances with the lowest price.
Strategies in Spot Fleet
1. LowestPrice – from pools with lowest cost.
2. Diversified – Distribute across all available pools.
3. CapacityOptimized – From pools with optimal capacity for number of instances.
4. PriceCapacityOptimized – this is the recommended approach. Select from the pools with highest capacity avaiblable and then the lowest price.