Skip to content
Related Articles

Related Articles

Amazon Web Services – Spot Rules in EC2 Spot Instances

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 08 Mar, 2022

In this article, we are going to walk through a few simple rules to follow when launching Amazon EC2 spot instances. Spot instances enable you to optimize costs on an AWS cloud and scale the throughput of your application up to 10 times for the same budget.

In this article, we will discuss two simple rules to follow when thinking about launching spot instances:

Rule 1: 

Spot pools have separate prices and change less frequently. Each instance type, size, and availability zone in every region is a separate spot pool. 

For example, take a look at the below image where c3.2xlarge in us-east-1c has a separate price and for c4.8xlarge in us-east-1d has a separate price for c3.2xlarge  is $10.9 right now. But it could be $0.9 tomorrow and it adjusts based on long-term supply and demand.

c3.2xlarge on US east 1c

c4.8xlarge on US east 1d

Rule 2:

Amazon EC2 will give you a two-minute warning when AWS needs the capacity back. 

You can request spot capacity similar to on-demand and always pay the current spot price. When AWS needs the capacity back, you will get a two-minute warning. AWS sends you the notification about the spot instant status. There are two reasons your spot instance could be marked for termination:

  1. The current spot price has risen above your maximum willingness to pay.
  2. The capacity is no longer available to serve your instance.

The bit status of your spot instance request is set to marked for termination and spot termination time metadata is set to a time precisely two minutes in the future.

Example 1: Response you will get when you call describe-spot-instance-requests API for the instance that got marked for termination.

"Status": {
            "Update Time" : "2022-03-02T18:16:21.000z",
            "Code" : "marked-for-termination",
            "Message" : "The Spot Instance is marked for termination",
        },

Example 2: Response you will get when you call describe-spot-instance-requests API for the instance that got terminated.

"Status": {
            "Update Time" : "2022-03-02T18:16:21.000z",
            "Code" : "instance-terminated-capacity-oversubscribed",
            "Message" : "Your Spot Instance was terminated as there
                            is no more unused capacity available
                            in this pool.",
        },
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!