What are Spot Instances?
An AWS EC2 Spot Instance is an unused EC2 instance which is available for less than the On-Demand price. Spot instances are up to 90% cheaper than On-Demand instances, which can significantly reduce your EC2 costs. A Spot Price is the hourly rate for a Spot instance. AWS sets the Spot price for each instance type in each availability zone based on the evolving supply and demand for Spot instances. Spot instances are cost-effective when you can be flexible with your application’s availability and when your applications can be interrupted after a two-minute warning notification.
Spot instances are ideal for stateless, error-tolerant, or flexible applications like data analysis, batch jobs, background processing, and optional tasks. These instances are closely integrated with AWS services like Auto Scaling, EMR, ECS, CloudFormation, Data Pipeline, and AWS Batch. You can easily combine Spot instances with On-Demand, RI, and Savings Plans instances to optimize workload costs and performance.
Reasons to Use Spot Instances
- Low prices
- Massive scale
- Easy to use
- Easy to automate
- Supports other AWS services
Spot Instances VS On-Demand Instances
Metrics | Spot Instances | On-Demand Instances |
---|---|---|
Launch time | Launches instantly if the Spot Request is active and capacity is available. | Launches instantly when you make a manual launch request and capacity is available. |
Available capacity | Delivers launch requests until capacity becomes available. | Sends an insufficient capacity error when the request is made and no capacity is available. |
Hourly price | Varies depending on supply and demand. | Remains the same. |
Rebalance recommendation | Sends a warning signal when the instance is at high risk for interruption. | Continues to run until you terminate or hibernate the instance. |
Instance interruption | Interruptible by AWS EC2 when capacity is no longer available, the prices exceed your budgeted max rate, or the demand for Spot instances increases. | Remains uninterrupted until you terminate or hibernate the instance. |
Strategies for Using Spot Instances
There are 2 key strategies for using Spot Instances:
- Maintain a minimum number of compute resources by launching a core group of On-Demand Instances and supplementing them with Spot Instances when required.
- Launch Spot instances with a fixed duration, called Spot blocks, which are designed to be uninterrupted and run continuously for the duration you choose.
Spot Instance Best Practices
- Prepare individual instances for interruptions: The best way to be fault-tolerant is to handle Spot instance interruptions with smooth workload rebalancing. Use EC2 instance rebalance recommendations and Spot Instance interruption notices to avoid feeling any hard cutoffs.
- Be flexible in terms of instance types and availability zones: A Spot instance pool consists of unused EC2 instances with the same instance type and availability zone. You should be flexible about which instance types you request and in which Availability Zones. Read our article in this series related to AWS Data Transfer Pricing to consider the additional cost of data transfers.
- Use EC2 Auto Scaling groups or Spot Fleet to manage your total capacity: Spot allows total capacity with vCPUs, storage, storage or network throughput. Auto Scaling groups and Spot Fleet allow you to start and maintain a target capacity and automatically request resources.
- Use the capacity-optimized allocation strategy: Allocation strategies in auto-scaling groups help you deploy your target capacity without manually searching for the Spot instance pools with free capacity.
- Use proactive capacity balancing: Capacity rebalancing helps maintain availability by adding a new Spot instance to the fleet before a running Spot instance receives the two-minute notification. It balances the capacity-optimized allocation strategy and the policy of mixed entities.
- Use integrated AWS services to manage your Spot instances: Other AWS services like EMR, ECS, AWS Batch, EKS, SageMaker, AWS Elastic Beanstalk, and GameLift integrate with Spot to reduce total invoice costs without having to manage individual instances or fleets.
Deploying Spot Instances
A Spot instance can be started in 2 different ways: you can either create a Spot Instance request or have AWS EC2 create one on your behalf. When starting a Spot instance, it is important to know that Spot pools have their own rates and these rates change less often. AWS will give you a 2-minute warning before taking back any Spot capacity you are using.
Request Methods
Requests can be made using any of the following:
Launch Locations
Spot Instances can be launched in 3 different places in AWS:
- Within a launch group.
- Within an Availability Zone group.
- Within a Virtual Private Cloud (VPC).
Spot Fleets
A Spot fleet is a collection of Spot instances (note that this collection can optionally contain On-Demand instances as well). The target capacity you specify in the Spot Fleet request defines the number of Spot instances and On-Demand instances. Requests for Spot instances are fulfilled whenever 1) spare capacity is available and 2) the maximum rate specified in your request exceeds the current Spot rate. Spot Fleets strive to maintain their target capacity, meaning they will launch new spot instances to regain capacity if fleet members are terminated. You can set a maximum hourly rate for your fleet and Spot Fleet will continue launch instances until that amount has been met. When your hourly rate is met, the Spot Fleet stops starting instances even if the target capacity has not been reached.
See the best multi-cloud management solution on the market, and when you book & attend your CloudBolt demo we’ll send you a $75 Amazon Gift Card.
Key Features of Spot Fleets
- Amazon EC2 auto scaling integration
- Optimized for cost
- Reduce the likelihood of interruptions
- On-Demand run instances function integration
- Stop/Hibernate and resume workloads
- Track when Spot instances run and terminate
- Amazon EMR integration
- Amazon CloudFormation integration
- Amazon ECS integration
- Amazon Batch integration
- Attach encrypted EBS volumes at launch
- Control your Spot Instance budget
- Support for Third Party Integration
Important Spot Instance Concepts
Spot Instance Request
A Spot Instance Request defines the number of instances, instance types, availability zones, and the maximum hourly rate you are willing to pay per instance. As soon as the maximum price exceeds the current Spot price and capacity is available, EC2 instances will immediately respond to the request. Otherwise, EC2 instances will wait until the request can be fulfilled or until the request is cancelled. The one-time or persistent request type determines whether the request is reopened when EC2 interrupts a Spot instance or when you stop a Spot instance. If the request is persistent, the request is opened again after your Spot Instance is interrupted. If the request is not persistent and you stop your Spot instance, the request only opens after you start your Spot Instance.
Spot Instance Interruptions
Spot Instance interruption is when EC2 instances reclaim a Spot instance’s capacity to meet capacity commitments for reservations or On-Demand use. The demand for Spot instances can vary considerably from moment to moment, and the availability of Spot instances depends on how many unused EC2 instances are available. There is a possibility that your Spot instance will be interrupted, so you need to make sure that your application is prepared to handle an interruption.
Rebalance Recommendations
An EC2 Instance Rebalance Recommendations is a signal that notifies you when a Spot Instance is at high risk of interruption. The notification comes earlier than the two-minute interruption of the Spot instance, giving you the ability to manage the Spot instance proactively. This allows you to rebalance your workload across new or existing Spot instances that are not at a high risk of interruption.
Spot Instance Advisor
The Spot Instance Advisor helps you identify pools with the least probability of disruption and offers the same savings you get over On-Demand rates. When selecting a Spot instance, you should account for the interruption tolerance of your application and your cost-saving goals. The lower the interrupt rate, the longer your Spot instances will likely run.
Spot Instance Limits
Spot Instance Limits are a limit on the number of ongoing and requested Spot instances per AWS account per region. These limits are defined by active and requested (pending) vCPU count. If you terminate your Spot instance but do not cancel the Spot instance request, the number of requests will not match your Spot instance vCPU limit until Amazon EC2 detects the Spot instance cancellations and closes the requests.
Burstable Performance Instances
If you start your Spot instances with a burstable performance instance type and plan to use them immediately and for a brief period without enough time for accruing CPU credits, it is recommended to run them in default mode to avoid higher costs. If you launch burstable performance Spot Instances in Unlimited Mode and burst the CPU immediately, you’ll spend surplus credits for bursting. If you use the instance for a short time, the instance will have no time to amass CPU credits to repay the excess credits, and you will be charged for the excess credits when you terminate the instance.
Platform
|
Multi Cloud Integrations
|
Cost Management
|
Security & Compliance
|
Provisioning Automation
|
Automated Discovery
|
Infrastructure Testing
|
Collaborative Exchange
|
---|---|---|---|---|---|---|---|
CloudHealth
|
✔
|
✔
|
✔
|
||||
Morpheus
|
✔
|
✔
|
✔
|
||||
CloudBolt
|
✔
|
✔
|
✔
|
✔
|
✔
|
✔
|
✔
|
Cost Saving Use Cases with AWS Spot Instances
- Big Data & Analytics: Big data, machine learning, and Natural Language Processing (NLP) workloads can be fast-tracked with Spot Instances. Spot instances provide acceleration, scaling, and deep cost savings for time-critical, hyper-scalable workloads needing rapid data analysis. Spot instances can be used with Amazon EMR, Hadoop, or Spark to handle enormous amounts of data.
- Containerized Workloads: Container clusters can be with Spot Instances at a fraction of the cost. Containers are stateless, fault-tolerant and ideal for Spot Instances. Spot clusters can be created with AWS ECS or Kubernetes to operate containerized workloads.
- High Performance Computing: Accelerate large computing tasks like genome sequencing, Computational Fluid Dynamics (CFD), and algorithmic trading by performing huge parallel jobs. Spot instances are integrated with AWS Batch, AWS CloudFormation and other AWS services, providing a complete solution for various large-scale computing workloads.
- Web Services: Save up to 90% on web services and applications with Spot instances. Deploy an EC2 Spot Fleet behind a load balancer to scale to tens of thousands of instances, serving billions of service requests with Spot Instances.
- CI/CD & Testing: Jenkins can be configured with the EC2 Spot Plug-In to scale Spot instance fleets based on the number of incomplete jobs that are in queue. You can increase cost savings by using smaller instances for CI, as these processes do not require much power for testing. Many workload types (canary, security testing) can be performed more cheaply via Spot instances.
- Image and Media Rendering: Media and entertainment studios can cost-effectively manage rendering workloads using Spot instances by scaling on-premises or cloud infrastructures with almost unlimited capacity, as required by projects and timelines.
Pricing and Cost Savings
Spot Instance Pricing model
You pay the Spot price only for the period your instances are operating. Spot Instance prices are set by EC2 and are adjusted based on trends in supply and demand. Spot instances are also available to operate for a predefined duration in hourly increments of up to 6 hours in length.
Spot Instance Pricing History
It is recommended you use the standard maximum On-Demand price when requesting Spot instances. If you want to specify a maximum price, review the Spot Instance Pricing History first. You can view the Spot instance pricing history for the last 90 days and filter by instance type, operating system, and availability.
Spot Instance Cost Saving
Usage and savings information for fleet-level Spot instances or all ongoing Spot instances can be viewed for cost-saving purposes. At fleet level, the usage and savings information includes all instances started and terminated by the fleet. You can view this information from as recently as the last hour or up to three days.
Spot Instance Data Feed
AWS EC2 provides a Spot Instance Data Feed that describes your Spot Instance use and pricing. This data feed is sent to an Amazon S3 bucket you specify when subscribing to the data feed. Data feed files are sent to the bucket hourly, and each usage hour is typically recorded in a single data file. These files are gzip-compressed before being delivered to your bucket. EC2 may write multiple files for a given usage hour if the data is too large.
Spot Instance Integration with Other AWS Services for Cost Savings
- Amazon EMR Integration: Operate AWS EMR clusters on Spot Instances to reduce the cost of processing massive amounts of data for Hadoop clusters. Simply mix Spot Instances with On-Demand and Reserved Instances using the instance fleet feature.
- AWS CloudFormation Integration: Organize and deploy AWS resources using CloudFormation scripts; CloudFormation also lets you describe dependencies and parameters to be passed in at runtime.
- Auto Scaling Integration: Manage Spot instances using Auto Scaling groups to maintain application availability; you can scale your Spot capacity automatically depending on any conditions or pricing rates you define.
- Amazon ECS Integration: Operate ECS Clusters on Spot instances to reduce the operational cost of maintaining your containerized applications.
- Amazon Batch Integration: Dynamically schedule your batch computing workloads for Spot instances to reduce the cost of performing your batch jobs.
Conclusion
Spot instances are an excellent way to lower your AWS spend, however it is important to keep in mind which kinds of applications or workloads best fit the nature of Spot instance usage. Spot Fleets also enable you to minimize the potential risks of using Spot instances when proper workload transition plans are set into place.
Related Blogs
The New FinOps Paradigm: Maximizing Cloud ROI
Featuring guest presenter Tracy Woo, Principal Analyst at Forrester Research In a world where 98% of enterprises are embracing FinOps,…
FinOps Evolved: Key Insights from Day One of FinOps X Europe 2024
The FinOps Foundation’s flagship conference has kicked off in Europe, and it’s set to be a remarkable event. Attendees familiar…