Crash course: Amazon EC2 pricing (and cutting your AWS bill)

Leon Kuperman
· 12 min read
Amazon EC2 pricing

Bonus content: Guide to Amazon EC2 instance types

AWS makes a DevOps life hard. How are you supposed to make sense of EC2 pricing when there are 400 different Amazon EC2 instances?

Picking the right VM type for the job is difficult. But it doesn’t have to be.

Read on for a quick introduction and AWS EC2 pricing and expert tips for slashing your cloud bill.

What you’ll find inside:

What are Amazon EC2 instances?

Amazon EC2 stands for Amazon Elastic Compute Cloud, a web service that brings you compute capacity in the cloud. AWS designed these instances to help developers reap the benefits of web-scale cloud computing.

The service offers almost 400 different instances with choices across processors (Intel, AMD, or Arm-based), storage options, networking, operating systems, and purchase models – across a total of 24 regions and 77 availability zones all over the world.

Amazon EC2 instance types

EC2 instance typeWhat you need to know
General purpose– Offers a balanced ratio of CPU to memory
– Good fit for general-purpose applications that use CPU and memory in equal proportions – for example, web servers with low to medium traffic or small to medium databases.
Compute optimized – Optimized for CPU-intensive workloadsHigh ratio of CPU to memory 
– Good fit for web servers with medium traffic, batch preprocessing, network appliances, and application servers
Memory optimized – Comes with a high memory-to-CPU ratio
– Great fit for production workloads – for example, database servers, relational database services, analytics, and larger in-memory caches.
Storage optimized– Good choice for workloads that require heavy read/write operations and low latency 
– Thanks to high disk throughput and IO, storage-optimized instances come in handy for Big Data, SQL and NoSQL databases, data warehousing, and large transactional databases
Accelerated computing– Uses hardware accelerators (co-processors) to carry out functions like data pattern matching, graphics processing, and floating-point number calculations better than software running on CPUs 
– Great pick for machine learning (ML) and high-performance computing (HPC)
Inference type – Built to support machine learning applications
– AWS EC2 Inf1 promises up to 30% higher throughput and 45% lower cost per inference than AWS EC2 G4 instances
– Includes 16 AWS Inferentia chips, 2nd generation Intel® Xeon® Scalable processors, and up to 100 Gbps networking

Need more details? Read this: 400(!) EC2 instance types: the good, the bad, and the ugly

Quick guide to AWS EC2 pricing

AWS pricing


The pay-as-you-go model works well for many teams because they only get to pay for resources they actually use. You can increase or reduce your usage just-in-time without having to worry about any long-term binding contracts or upfront payments. This is how you also avoid the risk of overcommitting to a budget. 

How to hack On-Demand instances?

  • Don’t forget that this convenient option is also costly, so you’re risking overrunning your budget.
  • These flexible instances work well for unpredictable workloads with fluctuating traffic spikes—otherwise, better look into alternatives.

Reserved Instances 

It all looks great in theory. Buy capacity upfront for 1 or 3 years in a given availability zone and get a really good discount compared to On-Demand pricing. And the bigger your upfront payment, the bigger the discount.

How to hack Reserved Instances?

  • Better avoid them. What if you commit to resources that don’t make sense for your company in a year?
  • You’re committing to a specific instance or family. Changing this later isn’t possible. And what if your requirements change in the meantime? You’re blocked. 

Savings Plans 

Savings Plans work like Reserved Instances, only you’re committing to a specific amount of compute power to be used over 1 or 3 years. All the usage covered by your commitment will be covered, and you’ll pay the On-Demand rate for anything extra. 

How to hack Savings Plans?

  • Better avoid them.
  • You’re not committing to specific instance types and configurations, but you still run the risk of locking yourself in with the cloud vendor
  • Again, you commit to paying for resources that might make zero sense for your company in 1 or 3 years. 

This goes for both Reserved Instances and Savings Plans: When your requirements change, you either commit even more or get stuck with unused capacity.

These options prevent any flexibility of scaling, seasonality, or ability to configure multi-region/zone distribution easily.

Spot Instances

Spot instances offer an amazing opportunity to reduce cloud costs by getting instances at up to 90% off the On-Demand pricing. By bidding on resources AWS isn’t using, you get to save up and expose your workloads to potential interruption. AWS can pull the plug at any time and give you a 2-minute warning. 

How to hack Spot Instances?

Dedicated Hosts

This is basically a physical server that offers instance capacity exclusively to you. You get the resiliency and flexibility of AWS and the cost benefits of using your own licenses. 

How to hack Dedicated Hosts?

  • This is a good choice for companies looking to achieve compliance or avoid sharing hardware with other tenants for security reasons.
  • You’re billed hourly for every active Dedicated Host, not running instance. 
  • It’s an expensive option.

Whichever EC2 pricing model you choose, don’t forget about these extra charges

AWS charges for extra things like egress traffic, load balancing, block storage, IP addresses, and premium support. Consider these costs when comparing different pricing models and building your cloud budget.

5 tips for achieving the right EC2 pricing and performance combo 

1. Define your requirements

See an affordable instance? You might be tempted to get it. But what if it can’t handle your workload once you run a memory-intensive application? Prepare for poor performance that might affect the reputation of your entire company.

That’s why you need to start by clarifying your requirements. Compute costs are the biggest item on your cloud bill, so make a deliberate effort to order only what you actually need.

Consider your requirements across all compute dimensions:

  • CPU Count
  • CPU Architecture
  • Memory
  • SSD Storage 
  • Network

Let’s say that you’ve done your research, know your exact requirements, and found a targeted set of instance types that match them. Choosing the first “good enough” instance might backfire on you. EC2 instances come with various price vs. performance ratios. You might be able to secure better performance for the cloud compute dollar and slash your costs.

Next comes the question: Should you go for a CPU vs. GPU dense instance? 

If you’re building an application based on machine learning, go for GPU. They’re much faster when it comes to training models. 

And consider a specialized instance type like AWS EC2 Inf1 that is supposed to work really well for running predictions through your trained models.

Otherwise, a CPU-based instance will do the job.

2. Pick the right instance type, here’s how

AWS offers several instance types optimized for different use cases; just take a look at the table above. 

For each type, you can choose from one or more instance sizes. This allows scaling the resources to match your workload’s requirements.

But cloud service providers roll out different computers for these instances. And the chips in those computers have different performance characteristics. 

You might end up with an older-generation processor that is slightly slower or a faster, new-generation one. So, the instance you pick might have strong performance characteristics that you don’t even need. And you don’t even know about it!

Solution? You can verify this via benchmarking. Just drop the same workload on each machine type and check its performance. 

We did this at CAST AI when we started over a year ago. Here’s what we learned:  

Benchmarking case study: Unpredictable CPU behavior 

The chart below shows CPU operation in Amazon t2-2x large (8 virtual cores) at different times after several idle CPU periods.

Source: CAST AI

A note about processors: ARM-powered instances

AWS offers ARM-powered VMs like the AWS EC2 A1 family that uses a Graviton2 ARM processor. ARM is an interesting choice: it consumes less power, so running and cooling it is cheaper. That’s why cloud providers tend to charge less for this type of processor. 

But if you’d like to use it, you might have to re-architect your delivery pipeline and compile your application for ARM. Unless you’re already running an interpreted stack like Python, Ruby or NodeJS – then your applications are likely to run.

3. Take advantage of CPU bursting

Burstable performance instances were designed to offer a baseline level of CPU performance with the opportunity to burst to a higher level exactly when your workload needs it. 

Burstable performance instances are a good choice for low-latency interactive applications, microservices, small and medium databases, and product prototypes.

The number of accumulated CPU credits depends on the instance type. Larger instances collect more credits per hour. But they also come with a higher cutoff to the number of credits you can collect.

Here are a few facts about burstable performance instances in AWS:

  • They’re available in instance families: T2, T3, T3a, and T4g. 
  • Restarting an instance in the T2 family leads to losing all the accrued credits.
  • Restarting an instance in the T3 and T4 families means that your credits will persevere for seven days and then will be lost.

Our research into AWS burstable performance instances showed that if you load your instance for 4 hours or more each day on average, a non-burstable instance is a better choice. But if you run an e-commerce site that gets a large stream of visitors once in a while, it’s a good fit.

Also, CPU capacity tends to increase linearly during the first 4 hours. After that, it becomes much more limited, as in this example of T2.2Xlarge:

Source: CAST AI

4. Check storage transfer limitations

To cut costs, you need to consider data storage as well.  

AWS EC2 instances use Elastic Block Store (EBS) to store disk volumes. You can also get local ephemeral storage in AWS.

Each application comes with its unique storage needs. When picking an instance, ensure that it has a suitable storage throughput. 

Avoid pricey drive options like premium SSD unless you expect to use them to the fullest.

5. Take advantage of spot instances

Spot Instances are a great way to save up on your AWS bill. By bidding on instances AWS isn’t using, you can get up to a 90% discount on the On-Demand pricing.

To get started, make sure that your workload is a good candidate for Spot Instances by asking these questions:  

  • How much time does it need to finish the job? 
  • Is it a mission- and time-critical workload?
  • Can it tolerate interruptions well? 
  • Is it tightly coupled between instance nodes? 
  • What’s your strategy for moving your workload when AWS pulls the plug? 

When picking a Spot Instance, consider the less popular ones – the chances of getting interrupted are lower. 

You can also check an instance’s frequency of interruption. This is the rate at which the instance reclaimed capacity during the trailing month. Take a look at the AWS Spot Instance Advisor:

AWS spot instances frequency of interruption

Don’t be afraid of using Spot Instances for more important workloads. AWS offers an instance type that guarantees uninterrupted operation for up to 6 hours (in hourly increments). You have to pay a little more for it, but you’ll still get a 30-50% discount. 

When bidding your price, set one equal to the On-Demand pricing. Otherwise, the risk of your workload getting interrupted is higher once the price goes up.

Increase your chances of getting Spot Instances by setting up groups called AWS Spot Fleets. They allow you to request multiple instance types at the same time. And you’ll pay the maximum price per hour for the entire fleet, not a specific spot pool (instances with the same type, OS, availability zone, and network).

How to apply all of this?

Choosing the right EC2 instances manually is challenging task. But you can delegate this important job to an instance selection algorithm like the one we built at CAST AI. 

An algorithm like that can choose the best instance type to meet the application requirements whenever a cluster needs extra nodes. This means that your workloads will be running at maximum performance and minimum cost.

Here’s how it works: 

  1. At 15:41, the application receives a surge of unexpected traffic. The Horizontal Pod Autoscaler creates new pods, but they have no place to run. So, we get an instant requirement for 15.5 new CPU cores.
  2. Within 2 minutes, CAST AI adds a new 16-core node automatically.
  3. At 15:45, additional traffic appears in the application.
  4. To manage this, it adds an extra 8-core node within one minute.
  5. Once the traffic is gone, CAST AI instantly retires 2 nodes to avoid resource waste.

Note that the cost optimization engine selected Spot Instances for the extra work available at a large discount.

If you use the Amazon EC2 instances to run Kubernetes clusters, you can get automated instance selection and rightsizing with EKS Optimizer – head over to this page and generate a savings report to see how much you stand to save on your cloud bill.

Leave a reply

Inline Feedbacks
View all comments
2021-05-21 9:48 AM

I guess picking the right instance type is the best tip that you can give and of course the automation of this is the perfect scenario everyone is looking for

2021-05-21 10:19 AM

I’m not sure I understand the unpredictable CPU usage case study clearly enough, can you explain it a bit more?

2021-05-21 10:52 AM

The fact that there’s 400 amazon ec2 instances is just mind boggling

2021-05-25 10:10 AM

A comprehensive ec2 pricing guide indeed

2021-06-02 7:54 AM

will CAST automatically pick the best spot instance for my cluster?

2021-06-02 8:38 AM

Does the automation tool select the proper instance for the proper workload and how does it know what’s required?

2021-06-04 9:51 AM

if the automation knows when to pick what, you’ve got my money

Matt P.
2021-06-09 8:05 AM

is there a case study for this?

2021-06-17 9:34 AM

Very informative post

2021-06-17 11:06 AM

great read. I like how you provided your own benchmarking, would be curious to see more in the future, helps with perspective

2021-07-02 8:42 AM

As a beginner in to my AWS courses, I found this to be helpful, will save it for future references

marco de.
2021-07-02 8:47 AM

Our team has yet to master the AWS instances and when to use them at the appropriate situations, which results us in over provisioning a lot of resources, but this ec2 pricing guide will be helpful for my whole team

2021-07-02 9:02 AM

We need to massage our team with the spot instances more, or decide on the automation tool that uses them intelligently since it seems that we are not as efficient that I would like us to be..

2021-07-20 11:39 AM

some good tips about ec2 pricing

2021-07-22 2:03 PM

so does CAST automate selection between those 400 instances or how does it work