EC2 Pricing and How to Save Up on It: Crash Course

Bonus content: Guide to Amazon EC2 instance types

AWS doesn’t make a developer’s life easier. How are you supposed to make sense of EC2 pricing when there are so many different EC2 instance types out there?

EC2 Pricing and How to Save Up on It: Crash Course

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 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 virtual machines to help developers reap the benefits of web-scale cloud computing.

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

EC2 instance types

EC2 pricing

General purpose

This EC2 instance type offers a balanced ratio of CPU to memory. It’s a 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 

This type is optimized for CPU-intensive workloads, so it comes with a high ratio of CPU to memory. Pick it for web servers with medium traffic, batch preprocessing, network appliances, and application servers.

Memory optimized

This EC2 instance type has a high memory-to-CPU ratio. It’s a great fit for production workloads – for example, database servers, relational database services, analytics, and larger in-memory caches.

Storage optimized

Choose this EC2 instance type 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

This instance type 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. A great choice for machine learning (ML) and high-performance computing (HPC).

Inference type 

AWS designed this EC2 instance type to support machine learning applications. AWS EC2 Inf1 promises up to 30% higher throughput and 45% lower cost per inference than AWS EC2 G4 instance. It includes 16 AWS Inferentia chips, 2nd generation Intel® Xeon® Scalable processors, and up to 100 Gbps networking.

Read this to learn more: 400(!) EC2 instance types: the good, the bad, and the ugly

Quick guide to AWS EC2 pricing

AWS pricing

On-Demand 

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.

Are you running on AWS Savings Plans? You can still reduce your cloud bill, here’s how

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. However, this EC2 pricing model comes at a price. 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 Amazon 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.

CPU operation in Amazon t2-2x large

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:

Workload in hours

Source: CAST AI

4. Check storage transfer limitations

To cut costs on EC2 pricing, 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 instances and fixing EC2 pricing manually is a 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: 

Cluster CPU
  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 start your journey with automation now. Run a free Savings report to see how much you can save on your EC2 charges.

Get your free
Savings Report

Takes under 5 minutes to run,
no credit card required

___

FAQ

What is an EC2 instance?

An Amazon EC2 instance is a virtual machine located in Amazon’s Elastic Compute Cloud (EC2) that allows teams to run applications on the Amazon Web Services (AWS) infrastructure.

This scalable service is designed for flexibility and convenience, as it comes with a user-friendly interface that gives complete control over cloud resources.

An Amazon EC2 instance can act as a virtual server hosted in the AWS cloud. There are many types of Amazon EC2 instances available, each ideal for different needs, using various operating systems (OS), applications, and other customizable features.

What are the types of EC2 instances?

Amazon EC2 offers a variety of instance types, each tailored to a particular type of workload. Naturally, each type comes at a different EC2 pricing level. Instance types include combinations of CPU, memory, storage, and networking capacity, allowing you to choose the mix that is most appropriate for your application.

The instance size determines the memory and CPU resources available on an instance, enabling you to scale your resource allocation as needed.

For example, general-purpose instances provide a good balance of CPU, memory, and networking resources for a range of diverse workloads, making them suitable for a variety of applications such as web servers and code repositories.

Compute-optimized instances are highly performant instances designed for compute-intensive applications that use large amounts of processor power. And memory optimized instances are designed to process large amounts of data in memory, making them ideal for applications that need to run high volumes of concurrent requests or queries. These are just three examples of EC2 instance types.

How many EC2 instances are there?

AWS currently offers almost 400 different instances with choices across storage options, networking, operating systems.

What are the different types of EC2 instances based on their costs?

Users can choose from five pricing models for Amazon EC2 instances: On-Demand Instances, Reserved Instances, Savings Plans, Spot Instances, and Dedicated Hosts.

What is Amazon EC2 pricing?

EC2 pricing tiers and models significantly impact billing charges, as well as optimization features like Amazon EC2 Auto Scaling and AWS Compute Optimizer.

How does EC2 pricing work?

EC2 pricing refers to different models AWS uses to bill its EC2 services. Currently, AWS users can choose from five different models:
– On-Demand – this is the most expensive and flexible option based on pay-as-you-go, meaning that you pay for the exact resources you use.
– Reserved Instances and Savings Plans – these two options offer great discounts based on upfront payments for specific resources or usage levels. These two EC2 pricing models are popular among companies that use massive volumes of cloud resources, but they come with a 1- or 3-year commitment.
– Spot instances – this model offers incredible discounts on cloud resources that any AWS customers aren’t using. Still, once a customer buys the capacity, AWS pulls the plug on the spot instance. Teams looking to benefit from spot need to have a mechanism to handle this interruption. This is where automation can help a lot.
– Dedicated Hosts – this is an optimal solution for businesses in highly-regulated industries that want to benefit from the cloud but cannot share resources with other organizations.

How often does spot pricing change for EC2?

AWS launched a new Amazon EC2 Spot model at re:Invent 2017 to allow customers to reserve instances at a discount. The new model provides predictable prices that adjust slowly over days and weeks, with typical savings of 70-90% over On-Demand.

The previous pricing model that gave users free reign in the marketplace, made it hard to estimate the bidding strategy and the price for spot instances.

Now you pay a spot cost that’s in effect for the current hour for the instances that you launch. You can also focus on running your business without having to spend time analyzing market prices or setting maximum bid prices.

Spot instances receive a two-minute interruption notice when they’re about to be reclaimed by EC2. AWS has also reduced interruption times with this new EC2 Spot model.

  • Blog
  • EC2 Pricing and How to Save Up on It: Crash Course

Leave a reply

20 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kabal
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

xcav
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?

Vidmantas CAST AI
2021-06-07 4:28 AM
Reply to  xcav

Hi, can you specify which parts confuses you?

....
2021-05-21 10:52 AM

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

Williams
2021-05-25 10:10 AM

A comprehensive ec2 pricing guide indeed

rakesh
2021-06-02 7:54 AM

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

Vidmantas CAST AI
2021-06-07 4:29 AM
Reply to  rakesh

CAST AI will strike for the best price-performance ratio and pick the most optimal spot instance for your cluster and workload.

Last edited 1 year ago by Vidmantas CAST AI
curious
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?

Vidmantas CAST AI
2021-06-07 4:29 AM
Reply to  curious

CAST AI algorithm finds the best price-performance ratio and takes overhead into account when calculating what would be a most suited instance for the workload. In the near future, you will be able to specify parameters and customize the requirements for the instances.

Last edited 1 year ago by Vidmantas CAST AI
han.
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?

Vidmantas CAST AI
2021-07-23 10:42 AM
Reply to  Matt P.

Hi, Matt. Thank you for your question. You can check our case studies here: https://cast.ai/case-studies/

Tech-Act
2021-06-17 9:34 AM

Very informative post

Lynn
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

noname
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

hughes
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..

nice
2021-07-20 11:39 AM

some good tips about ec2 pricing

Jacob
2021-07-22 2:03 PM

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

Vidmantas CAST AI
2021-07-23 10:43 AM
Reply to  Jacob

Hi, Jacob. Thank you for your question. CAST algorithm picks the best price-performance ratio for your cluster. In the near future, you will be able to specify parameters and customize them further.

Recent posts