A spot instance in AWS allows us to bid for the unused EC2 capacity in the AWS cloud. This enables us to get EC2 instances at steep discounts, significantly bringing down the cost.
The hourly price for a spot instance is called a spot price. The spot price for each EC2 instance type is set by Amazon EC2. This price is different in each availability zone.
The price is determined by long-term supply and demand.
Our spot instance runs whenever capacity is available, and the maximum price per hour we provided in the request is greater than the spot price.
Spot instances should only be used for non-critical workloads.
A spot instance request can either be a one time request
or persistent
request. A typical request follows the following flow:
When we try to launch an EC2 instance using the AWS console, we can select spot instance in the advanced settings. This creates a spot instance request and follows the above workflow.
Spot instances are an excellent way to reduce our AWS hosting cost. They’re recommended for stateless, fault-tolerant applications and are okay with interruptions. While running, spot instances are the same as on-demand instances. However, there are no guarantees on their availability, and the spot instance can be terminated with just a notice of two minutes.