You Should Move Compute To AWS EC2 Spot Instances

Chris FullerBill Optimisation7 Comments

Amazon are celebrating 10 years of AWS. On Amazon’s celebration page, they include an interesting insight regarding EC2 Spot Instances:

“On average, every week, AWS customers are using more compute capacity on Amazon EC2 spot instances than customers in 2012 were running across all of Amazon EC2”https://aws.amazon.com/10year

Although many customers are utilising spot instances, AWS have made it so easy to launch on-demand instances that customers typically have the majority of their compute on the more costly on-demand pricing model.

Spot instances require the customer to identify the types of workload that can be handled by spot instances and understand the bidding process.

Spot instances can suit workloads that are time flexible and not sensitive to interruption e.g. Media encoding, scientific computing or financial modelling. Spot instances integrate with other services such as Auto Scaling, VPC, CloudFormation and EMR so they can be incorporated into existing architectures.

To make a spot instance request, a bid price must be submitted. Spot Bid Advisor gives customers an idea how likely a bid price of 25%, 50% and 100% of the on-demand instance price is likely to be outbid. Example for 25% of the on-demand price for m3.medium instances in the Asian Pacific (Sydney) region right now:

Instance Type vCPU Memory (GiB) Savings over On-Demand Frequency of being outbid (month) Frequency of being outbid (week)
m3.medium 1 3.75 84% Low Low

From this, it looks likely that we can get some m3.medium spot instances for 25% of the on-demand price. The on-demand price is currently $0.093 per hour in Sydney (https://aws.amazon.com/ec2/pricing) so $0.02 could be a high enough bid price.

To illustrate this, GorillaStack have open sourced this CloudFormation template to create a spot request for a 2 instance “fleet” of m3.medium instances for $0.02 per hour each: You can grab it from GorillaStack Github now.

Spot Fleets are a convenient way to manage EC2 spot instances. A fleet can be anything from one EC2 instance to thousands that are all working together as part of a distributed application. The instances may come and go from time to time as Spot prices change or if the fleet’s capacity is updated, but the fleet itself retains its identity and its properties.

At GorillaStack, we are relentless at finding AWS Cost Optimsations and spot instances & fleets can help to reduce cost. “You can save up to 90% [using spot instances] compared to on-demand prices.” – AWS EC2 console (beta version).

Spot Bid Advisor is a good resource but we need to programmatically determine prices to automate anything. AWS provide spot price history for the past 90 days through their CLI and SDKs. Check out this example that uses the JavaScript SDK to get spot price history for m3.medium Linux/UNIX instances in all Sydney availability zones:

0.014500 was the price which you have to bid to guarantee that a single Spot request is fulfilled which later rose to 0.014700. If your bid price is below 0.014700 then AWS will terminate your spot instance(s) that are in service. Your bid price will be a trade off against uptime and speed of request fulfilment. Just like the financial markets: Keep in mind that the historical trends are not a guarantee of future results.

We believe that there’s a significant opportunity for AWS technology partners such as GorillaStack to help companies with their forays into the spot instance market space. Follow us to keep an eye on future developments.

In the meantime, what would help your company utilise spot instances? We’re constantly looking for ways to help our customers save money in the Cloud.

Happy bidding.

7 Comments on “You Should Move Compute To AWS EC2 Spot Instances”

  1. Pingback: AWS Week in Review – March 28, 2016 | Tech News

  2. Pingback: AWS Week in Review – March 28, 2016 - Browser Zone

  3. So what I’m trying to figure out is why i’d be worried about interruption? After I get my hands on a spot instance, what would happen that it would then get taken away? Is it predictable when that might happen? If not, then are spot instances just for temporary non priority computing tasks?

    1. Hi Mystic. Here’s an example where you could be worried about interruption: If you were running a workload where it was critical that some computation finished in a certain time and a percentage of instances running the workload were spot instances and they went down, the computation time could increase.

      You can try to predict when an instance will go down based on the spot price history.

      Spot instances don’t have to be for just non-priority / temporary tasks. E.g. you could use them for running a high-priority task (e.g. running a website) but combine them with on-demand / reserved instances to ensure a set number of instances always exist but at the same time, saving costs with spot as traffic changes. More information here: https://aws.amazon.com/blogs/compute/an-ec2-spot-architecture-for-web-applications/

  4. Spot fleets are great, but the migration effort is non-trivial if you already have AutoScaling groups in place, and you need to work around some limitations.

    I personally prefer AutoScaling wherever possible, but the official spot implementation on AutoScaling is risky, so I wrote a tool that tries to bridge this gap.

    It monitors existing on-demand AutoScaling groups where it was enabled (it needs a certain tag to be set on the group) and keeps replacing any on-demand instances it can find in those groups with compatible but also diversified spot instances, until you only have spot instances left in the group.

    It doesn’t interfere with the group’s launch configuration so any replacement or scaling would give you on-demand instances, so you don’t need to wait for spot instance fulfillment when you need it most.

    You can check it out on GitHub: https://github.com/cristim/autospotting

    1. This project looks really interesting – we’ll have a play around with it! Thanks for sharing.

      1. Please let me know if it worked for you and if you have any feedback it would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *