How to Find the Current AWS EC2 Spot Market Price
Have you ever wondered how to find the current market spot price for an EC2 instance? When people first hear that spot instances can save you up 50%-90%, they tend to react in disbelief. This is natural and understandable, it just sounds too good to be true. Fortunately, there are many ways to confirm that the 50%-90% spot price savings is real. This article tries to lists the many ways in one place.
Spot Pricing Page
Let’s start off with the public pages. The first one is the Amazon EC2 Spot Instances Pricing. Here we can select the region, and we get a simple list of instances and spot prices. The listing shows hourly prices and does not include the percentage savings.
Spot Instance Advisor Page
From the same Amazon EC2 Spot Instances Pricing page there’s a link to the Spot Instance Advisor page. You can also google for “Spot Instance Advisor” to find it. This page is also public. The advisor page provides a simple calculated list. You input how many CPUs and Memory you would like, and it instantly updates with a list with instance types that meet your requirements. It’s nice that it shows how much you’ll save in percentage vs. on-demand. It also shows an interesting “Frequency of Interruption” percentage. Most instances are interrupted less than 5% of the time.
EC2 Console Pricing History
The next way to check on spot instance pricing requires logging into your AWS account. There is a Pricing History Chart link that brings a chart which shows prices over time. This is a neat way and one of my favorite ways to see the spot price of an instance.
Here’s a summary of how to get to there:
- Go to the EC2 console
- Click on Spot Requests on the left-hand side menu
- Click on Pricing History in the upper menu.
Here’s where the Pricing History button is:
After you have selected instances and clicked on the Pricing History button, you’ll be able to choose an instance type. It is interesting to change the date range to 3 months to see how much spot prices have changed.
Also, if you go a little deeper and click on Request Spot Instances, choose some Instance Types, click Select, and then click the Pricing History button, you can select multiple instances and compare them all in one chart. Similar steps to get to these charts are also provided in the AWS EC2 Guide Docs.
EC2 Console Launch Instance Wizard Spot Option
We can also see spot pricing when launching an instance with the EC2 Launch Wizard. This is available in Step 3 Configure Instance of the wizard with the Request Spot Instances option.
AWS CLI
Next, I’ll show you how to find the current spot price with the aws cli describe-spot-price-history command. I like this method because it is quick and handy when you already have the aws cli installed. The command lists the spot prices for all AZs in a region for a specific instance type. Here’s the command:
$ aws ec2 describe-spot-price-history --start-time=$(date +%s) --product-descriptions="Linux/UNIX" --query 'SpotPriceHistory[*].{az:AvailabilityZone, price:SpotPrice}' --instance-types c5.large
[
{
"az": "us-west-2b",
"price": "0.034200"
},
{
"az": "us-west-2d",
"price": "0.032200"
},
{
"az": "us-west-2c",
"price": "0.034000"
},
{
"az": "us-west-2a",
"price": "0.033200"
}
]
$
You can also get the current spot price with the aws-sdk of your choice. I was pleasantly surprised to it’s possible to get the spot price with the cli and aws-sdk.
Here’s a one-liner that will do a little math and tell you what the monthly price for the spot instance is.
$ I=t3.small ; printf "\$%.2f/mo\n" $(echo "$(aws ec2 describe-spot-price-history --instance-types $I --start-time=$(date +%s) --product-descriptions="Linux/UNIX" | jq -r '.SpotPriceHistory[0].SpotPrice') * 24 * 30" | bc)
$4.68/mo
And here’s a loop that does a similar thing with a list of instances:
for I in t3.small t3.medium m5.large; do
printf "$I: \$%.2f/mo\n" $(echo "$(aws ec2 describe-spot-price-history --instance-types $I --start-time=$(date +%s) --product-descriptions="Linux/UNIX" | jq -r '.SpotPriceHistory[0].SpotPrice') * 24 * 30" | bc)
done
You should see something like this:
t3.small: $4.68/mo
t3.medium: $9.14/mo
m5.large: $28.58/mo
Normal EC2 Pricing
Here’s also how to check standard on-demand EC2 pricing. For that, I find it convenient to use this site: ec2instances.info. The site scrapes several pages to produce a list that is quite user-friendly. It’s handy to change the cost to a monthly basis, select the instances you’re interested in and click Compare Selected.
Summary
Okay, we went over several ways showing how to find current EC2 instance spot market prices. If you’re interested learning more about Spot Compute, check out: BoltOps Learn videos on Spot.
Thanks for reading this far. If you found this article useful, I'd really appreciate it if you share this article so others can find it too! Thanks 😁 Also follow me on Twitter.
Got questions? Check out BoltOps.
You might also like
More tools:
-
Kubes
Kubes: Kubernetes Deployment Tool
Kubes is a Kubernetes Deployment Tool. It builds the docker image, creates the Kubernetes YAML, and runs kubectl apply. It automates the deployment process and saves you precious finger-typing energy.
-
Jets
Jets: The Ruby Serverless Framework
Ruby on Jets allows you to create and deploy serverless services with ease, and to seamlessly glue AWS services together with the most beautiful dynamic language: Ruby. It includes everything you need to build an API and deploy it to AWS Lambda. Jets leverages the power of Ruby to make serverless joyful for everyone.
-
Lono
Lono: The CloudFormation Framework
Building infrastructure-as-code is challenging. Lono makes it much easier and fun. It includes everything you need to manage and deploy infrastructure-as-code.