Table of contents
1.
Introduction
2.
Spot Instances
3.
Spot Instance Interruptions
4.
Pricing History
5.
Getting started
6.
Strategies to use Spot Instances 
7.
AWS Spot Fleet
8.
FAQs 
8.1.
How is a Spot Instance different from an On-Demand instance?
8.2.
What is the benefit if a Spot instance hibernates on interruption?
9.
Conclusion
Last Updated: Mar 27, 2024
Easy

AWS EC2 Spot Instances

Author Yashesvinee V
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

An instance is a virtual server in the cloud. Every instance type offers different compute and memory capacities. Instances are chosen based on the computing power required for an application or software. Amazon Elastic Compute Cloud or Amazon EC2 provides scalable computing capacity in the AWS Cloud. Amazon EC2 eliminates the need to invest in hardware upfront and can help develop and deploy applications faster. AWS offers EC2 spot instances to spare capacity that significantly reduces the Amazon EC2 cost.

Spot Instances

Amazon EC2 Spot Instances allow developers to access spare Amazon EC2 capacity. Since Spot Instances are available at up to 90% off on On-Demand pricing, one can significantly reduce the cost of running their applications. AWS allows its clients to use services for a short term and helps reduce billing costs. EC2 Spot Instances can be reclaimed with a two-minute warning when EC2 needs the capacity back. This makes Spot Instances a great fit for fault-tolerant and stateless applications. Using EC2 Spot Instances can significantly lower costs and increase the elasticity of web applications.

Spot Instance Interruptions

EC2 Spot Instances can be launched on spare EC2 capacity in exchange for returning them when Amazon EC2 needs the capacity back. The event of reclaiming the Spot instance is known as Spot Instance interruption. The interruptions occur when AWS requires an extra capability to service customers who purchased reserved instances.

When Amazon EC2 interrupts a Spot Instance, it terminates, stops, or hibernates the instance. AWS can terminate spot instances with just a 2-minute warning. Demand for Spot Instances and the availability of Spot instances vary from time to time. On-Demand Instances specified in an EC2 Fleet or Spot Fleet cannot be interrupted.

There are three possible reasons that may cause EC2 to interrupt the Spot instance.

  • When the Spot price is greater than the client’s maximum price.
     
  • When EC2 reclaims the instance mainly to repurpose capacity or for host maintenance and hardware decommission.
     
  • If a Spot request includes a constraint, they are terminated when the constraint can no longer be met.

Pricing History

Spot Instance prices are set by Amazon EC2 and are adjusted gradually based on the long-term trends in supply and demand for Spot Instances. While requesting EC2 Spot Instances, it is recommended to use the default maximum price so that, when the request is fulfilled, the Spot Instances launch at the current Spot price and not more than the On-Demand price. To view the Spot Instance pricing history, navigate to the Amazon EC2 console, choose Spot Requests and click on Pricing history.

Read more, Amazon Hirepro

Getting started

To create Spot Instances, the very first step is to get set up to use Amazon EC2. If you don’t have an account, sign up for a free tier here.

  1. Create a key pair and a security group at the Amazon EC2 console. Refer to the documentation to do this.
     
  2. Launch, set up and connect to an EC2 Linux instance. Refer here.
     
  3. Create a Spot Instance request. Refer here.
     

Spot instances can be launched in a launch group, an availability group or in a VPC (Virtual Private Cloud).

Strategies to use Spot Instances 

On-Demand instances can be launched immediately if a manual launch request is made and capacity is available. Spot instances are launched if the Spot Instance request is active and capacity is available. A minimum level of guaranteed compute resources can be maintained by launching a core group of On-Demand Instances, and supplementing them with Spot Instances when the opportunity arises.

Source

AWS Spot Fleet

An AWS Spot Fleet is a set of EC2 Spot Instances and optional On-Demand Instances launched based on criteria specified by the cloud user. The Spot Fleet selects Spot capacity pools that match the client’s needs and launches Spot Instances to meet the target capacity for the fleet. By default, Spot Fleets maintain target capacity by launching replacement instances after the Spot Instances in the fleet are terminated. Spot Fleet attempts to replace terminated instances using the lowest priced option available. If a Spot Fleet is submitted as a one-time request, it does not persist after the instances have been terminated. On-Demand Instance requests can also be included in a Spot Fleet request.

FAQs 

How is a Spot Instance different from an On-Demand instance?

Spot Instances and On-Demand or Reserved instances function the same way. The main differences are that Spot Instances offer a significant discount on the On-Demand prices, instances can be interrupted by Amazon EC2 for capacity requirements with a 2-minute notification, and Spot prices are adjusted gradually based on long term supply and demand for spare EC2 capacity.
 

What is the benefit if a Spot instance hibernates on interruption?

During hibernation, EC2 Spot instances will pause and resume around any interruptions so that workloads can pick up from exactly where they left off. The instances retain their state across shutdown-startup cycles.

Conclusion

This article extensively discusses EC2 Spot Instances in AWS. We hope that this blog has helped you enhance your knowledge of the need for AWS Spot Instances and its advantages. If you want to learn more, check out our articles on AWS License ManagerCloud Computing Infrastructure and Cloud Architecture. Learn more about Big Data, Microsoft Azure, AWS and Google Cloud. Refer to Important AWS Interview Questions to ace your Amazon Interviews.

Explore our Coding Ninjas Library and upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass