Crash Course: Amazon EC2 Pricing and Cutting Your AWS Bill

Quick introduction and Amazon EC2 pricing: discover the essentials of EC2 instance types and best practices for slashing your cloud costs.

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 instance types
  • A quick guide to AWS EC2 pricing
  • Tips for picking the right EC2 instance

1. Define your minimum requirements

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

3. Take advantage of CPU bursting

4. Check your storage transfer limitations

5. Take advantage of spot instances

  • Or solve AWS EC2 pricing with an automated solution

What Are Amazon EC2 Instances?

Amazon EC2 stands for Amazon Elastic Compute Cloud, a web service that brings you to 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 type

What 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

A Quick Guide to AWS EC2 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 do you 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 do you hack Reserved Instances?

  • You 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 computing 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 do you hack Savings Plans?

  • You 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 do you hack Spot Instances?

  • Pick them for workloads that can tolerate interruptions – for example, stateless application components like microservices or replicable applications. 
  • Read this guide to reap all the benefits of Spot Instances: Spot instances: How to reduce AWS, Azure, and GCP costs by 90%.

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 do you 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, we must consider this 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:

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 do You Apply All of This?

Choosing the right EC2 instances 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: 

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.


We ZippyOPS, Provide consulting, implementation, and management services on DevOps, DevSecOps, Cloud, Automated Ops, Microservices, Infrastructure, and Security

Services offered by us: https://www.zippyops.com/services

Our Products: https://www.zippyops.com/products

Our Solutions: https://www.zippyops.com/solutions

For Demo, videos check out YouTube Playlist: https://www.youtube.com/watch?v=4FYvPooN_Tg&list=PLCJ3JpanNyCfXlHahZhYgJH9-rV6ouPro





Relevant Blogs:

Removing the Bastion Host and Improving the Security in AWS 

A Guide to AWS Instance Scheduler 

Unexpected AWS Charges You Should Be Monitoring Closely 

Observability Recipes

Recent Comments

No comments

Leave a Comment