Getting Started with Spot Instances
Cloud providers, such as Amazon with their EC2 Spot instances, offer spare compute capacity available in cloud at steep discounts compared to normal On-Demand instances, often up to 80%. This allows cloud providers to sell their excess compute capacity, but with two major restrictions:
- Spot instances are reclaimed by the cloud provider with little warning
- Spot and On-Demand instances cannot be used together in a single Auto Scale group
PowerDown Spot Optimizer
PowerDown overcomes these restrictions and enables you to easily use Spot instances for production, development and test workloads. PowerDown allows you to mix Spot and On-Demand instances in a single Auto Scale group without compromising availability and achieve large savings to your cloud budget.
The PowerDown Spot Optimizer extends the AWS Auto Scale facility by directly managing the lifecycle of Spot instances. You define a desired number of Spot and On-Demand instances in your Auto Scale groups and PowerDown then monitors the group and ensures the group composition matches the desired state. PowerDown will create Spot instances and migrate workloads from On-Demand instances without downtime or impacting availability.
PowerDown employs two overriding algorithms:
- Make then Break
The "Failsafe" strategy means that if anything goes wrong when allocating a Spot instance, the recovery path is for the Auto Scale group to continue normal operation by allocating an On-Demand instance. For example: if there are insufficient Spot instances available in the Spot market, the Auto Scale group will simply populate the group with On-Demand instances. When the market recovers and Spot instances are available again, PowerDown will resume migrating workloads onto the Spot instances.
The "Make then Break" strategy means that PowerDown will create (make) a new Spot instance, wait for it to be healthy and add to a load balancer, before detaching and terminating the existing On-Demand instance. In this manner, availability and redundancy is fully maintained during the migration.
Using both strategies, PowerDown ensures the desired number and health of instances is maintained. Throughout, you have the confidence that the price you pay for instances will never be more than the On-Demand price and will typically be a steep discount (up to 80%) to the On-Demand price.
In reality, the Spot markets are now quite stable and you often see Spot instances lasting several weeks at a time without termination by AWS.
Spot Optimizer Algorithm
The Spot optimizer algorithm uses the following steps:
- Check the Auto Scale current number of instances against the desired spot number.
- If more Spot instances are desired, then identify an On-Demand instance to replace.
- Boost the Auto Scale group maximum parameter temporarily if required.
- Spin up a Spot instance using the Launch Template / Configuration and configuration from the On-Demand instance.
- Attach the Spot instance to Auto Scale group.
- Detach the On-Demand instance and wait for current requests to drain.
- Terminate On-Demand instance.
- Readjust the Auto Scale group maximum parameter if required.
- Repeat after a 2 minutes delay.
The PowerDown Spot Optimizer enables you to effectively and easily use Spot instances for your production workloads and reduce your EC2 compute costs by up to 80%. Coupled with the ability to schedule powering-down non-production loads when not required, you can achieve big reductions in your cloud spend.
Spot Reclamation Warnings
When AWS needs more servers for On-Demand customers, it may reclaim Spot servers to meet the need. Spot servers will be given a 2 minute warning so they can save state before they are terminated. PowerDown listens for this warning and proactively creates and attaches a replacement On-Demand server so that it will be ready and serving requests before the original Spot server is terminated. PowerDown does this to ensure availability during the transition.