Year-End Discount: 10% OFF 1-year and 20% OFF 2-year subscriptions!

Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

aws
ec2

What is a spot instance in AWS?

Anjana Shankar

Tired of LeetCode? 😩

Learn the 24 patterns to solve any coding interview question without getting lost in a maze of LeetCode-style practice problems. Practice your skills in a hands-on, setup-free coding environment. 💪

Overview

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.

Spot instance request

A spot instance request can either be a one time request or persistent request. A typical request follows the following flow:

Stop instance request flow

Spot instance creation at EC2 instance creation time

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.

widget

Conclusion

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.

RELATED TAGS

aws
ec2

Tired of LeetCode? 😩

Learn the 24 patterns to solve any coding interview question without getting lost in a maze of LeetCode-style practice problems. Practice your skills in a hands-on, setup-free coding environment. 💪

Keep Exploring
Related Courses