AWS Cost-Saving Tips Part 2: Spot Instances

AWS Cost-Saving Tips Part 2: Spot Instances In the first part of our series on cost-saving tips, we discussed AWS Reserved Instances, and how to utilize them for workload needs while optimizing spending on Amazon services.

In this installment, we will examine Spot Instances, the opposite of the guaranteed-capacity model of Reserved Instances. Spot Instances are an excess computing resource offered at an incredibly low price. There is, however, one caveat: the instance can be reclaimed by Amazon if it needs the capacity back. So how does one use these instances?

Use a Fluctuating Spot Rate to Save on Capacity Costs

Spot Instances are unused EC2 instances offered by Amazon at a significant discount to an On-Demand Instance. The price of Spot Instances fluctuate according to supply and demand, and bids are placed based on the maximum price one is willing to pay. If your bid price is higher than the current spot price, your instance will run. However, if the Spot price rises above your bid price, your instance will be terminated.

This unusual model offers an excellent way to utilize computing capacity at a very low price: Spot Instances can usually be purchased for one-fourth (sometimes even as low as one-tenth) of the On-Demand Instance price. This makes Spot Instances probably the most cost-effective choice for stateless workloads. They can simply run as long as they are offered at a price you authorize. When terminated, you won’t be affected by their loss. Common use cases for this type of instance include testing environments and batch processing jobs. In addition, Spot Instances are sometimes used for web crawling, image processing, and scientific computing.

How to Use a Spot Instance

To get started with Spot Instances, simply go to the Spot Instance section of an EC2 service and make a request. You can choose the number of instances you want to launch and select an instance type (you can choose multiple types as well). You can select other options like AMI to be used, Availability Zone in which to run them, EBS volumes, security groups, etc. Before finalizing your request, be sure to specify a maximum rate. You may set it yourself or use default settings that will set the maximum price as the current On-Demand rate. Make sure that your price is never too high because the Spot Instance rate can occasionally rise above the On-Demand price during periods of high demand.

Spot Instance Pricing History

Spot Instance rates are usually a fraction of the price for On-Demand instances. However, during demand spikes, Spot Instance rates can actually surpass the price of On-Demand instances. Source: AWS console screenshot.

 

Instead of making a Spot Instance request, you can select a Spot Fleet. Unlike a one-time request, a Spot Fleet tries to maintain your target capacity if your instances are terminated. This is very helpful because managing Spot requests can be time-consuming. In addition to automatically replacing terminated instances, you can use a Spot Fleet to scale up the number of running instances to 1,000. This scalability is great when you need to provision workers for a Hadoop cluster.

You can also request a Spot Block, which gives you Spot Instances for a specific duration of one to six hours without interruption. This is useful when you need some guaranteed cheap computing capacity for a short amount of time. However, there is an additional cost for using a Spot Block (rates rise the longer the requested duration). As a result, savings from Spot Instances will be more limited.

Tips for Spot Instances:

  • Make sure you check the pricing history for Spot Instances and set the maximum price accordingly. You don’t want your instance shut down too early, but you also don’t want to overpay if demand (and with it the price) goes up sharply.
  • When making a request for Spot Instances, rates can vary significantly between Availability Zones. Make sure you always select the zone with the cheapest fee.
  • Use Spot Instances only for workloads that won’t suffer from being interrupted. If you need uninterrupted access to computing capacity for less than six hours, consider using Spot Blocks.
  • Consider using Spot Instances together with Reserved Instances: use Reserved Instances only for the baseline performance, and deploy Spot Instances when traffic spikes occur in your environment.

Summary

Unlike the Reserved Instances that guarantee capacity with some limited discounts, the primary advantage of using Spot Instances is their low cost. Capacity, however, is not guaranteed (except with Spot Blocks), so you have to be prepared for the possibility that your instances could be terminated at any moment. This limits the use of Spot Instances to stateless workloads for the most part, but they should be included in your environment when possible because of the potential savings.

In the final installment in the series, we will take a look at AWS AutoScaling Groups and how they can be used to reduce unnecessary spending by optimizing resource usage.

Automating Instance Backup Using CPM

While using in-house scripts can provide for a basic backup solution, it doesn’t make business sense for organizations to invest in a fully-featured in-house backup solution, as it moves focus away from their business-critical tasks, while compromising corporate governance procedures (reliance on one individual means less automation, transparency, and efficiency).

Cloud Protection Manager (CPM) is an enterprise-class backup-recovery and disaster recovery solution designed for AWS EC2 covering all the essential backup and recovery features to ensure robustness of the backup and DR solution as well as simplifying processes and saving precious DevOps time. With CPM, you will be able to backup your RDS databases, EC2 instances, independent EBS volumes, RDS Aurora clusters and Redshift clusters as often as needed without accruing additional AWS storage costs.

CPM is available as a service model that allows users to manage multiple AWS accounts and configure policies and schedules to take automated snapshot backups. CPM also supports both cross-account and cross-region Disaster recovery. For additional information, try CPM for free for 30 days (no credit card needed) or book a demo!

Share this post →

You might also like: