AWS Knowledge

Amazon EC2 Pricing Explained and Simplified

Guillermo Ojeda

Aug 11, 2023

    Table of contents will appear here.
    Table of contents will appear here.
    Table of contents will appear here.

What is Amazon EC2

Amazon Elastic Compute Cloud (EC2) is the core compute service of AWS. It offers virtual machines called EC2 instances, which are readily available in minutes and are billed only when they're active. With EC2 you can launch your cloud infrastructure with just a few clicks, scale it when needed, and reduce capacity during off hours while only paying for the instances you're actually running.

How does Amazon EC2 work?

The most important component of EC2 are instances, which are essentially virtual servers in AWS's infrastructure. You can launch an instance whenever you need it, and it'll be available in less than a minute. Then you're free to use it however you want, including installing software, hosting applications, serving content or running any kind of process.

There are a few additional features that are part of EC2, and that will let you do more than just run a single server:

  • Amazon Machine Images (AMIs): When you're creating an instance, you select an AMI, which is a pre-configured package required to boot up the instance. It acts as a template containing the OS, software, libraries, and configurations. You can also create your own AMIs, which can contain your application already installed and configured.

  • Instance Types: Not all EC2 instances are equal, or equally priced. EC2 offers an array of instance types, with different configurations for CPU, memory, GPUs, network and storage. For example, you can deploy general purpose instances, or instances with a higher memory to CPU ratio, or instances with GPUs for graphics processing or artificial intelligence models. With this variety, you can launch the instance type that better suits your workload, and only pay for what you actually need.

  • Instance Sizes: Even within the same type, EC2 instances can come in different sizes. For example, you could run an m7i.large instance with 2 vCPUs and 8 GBs of memory, or an m7i.xlarge with 4 vCPUs and 16 GBs of memory. This flexibility in size lets you deploy only the resources you actually need, without overprovisioning.

  • Regions and Availability Zones: AWS infrastructure is spread worldwide and divided into regions. Each region has multiple isolated locations known as Availability Zones (AZs). Each EC2 instance runs in one AZ, and if you're running several EC2 instances they can be spread across multiple AZs for high availability.

Amazon EC2 instance families and types

EC2 offers different instance families and types, to better suit different workload requirements:

  • General Purpose: As the name suggests, these are jack-of-all-trades instances suitable for a wide range of workloads. The most common general purpose instance types are m7i powered by Intel processors, m7g powered by AWS's proprietary Graviton3 processors (ARM-based), and t4g, which are burstable instances that accumulate credits when CPU usage is low and then consume them to increase performance.

  • Compute Optimized: These types of instance have a higher CPU to memory ratio, which makes them suitable for workloads that are compute-intensive. The latest families are c7g (with Graviton3 processors) and c6i (with Intel processors).

  • Memory Optimized: These instances offer a higher memory to CPU ratio than general purpose instances, making them the best choice for workloads that don't consume a lot of CPU, but need a high amount of memory, such as caches and databases. The latest families are r7g and r7iz.

  • Accelerated Computing: Some types of calculations, such as graphics processing or machine learning algorithms, are better run on GPUs than on CPUs. Accelerated computing instances offer GPU co-processors that make them much better for these types of workloads. The most common families are p5, g5g and inf2.

  • Storage Optimized: These instances have a dedicated array of high-speed AWS Nitro SSDs directly attached to the hardware, which lets them perform disk IOPS with a much higher throughput, lower latency and lower latency variability than instances using EBS volumes as storage. The latest families are i4g and i4i.

  • HPC Optimized: HPC stands for High Performance Computing. These instances are optimized for high performance, highly parallelizable CPU workloads, such as computational fluid dynamics, weather forecasting or multiphysics simulations.

Pricing varies per instance type and size. For example, a t4g.micro is really cheap but it might not be a good fit for compute-intensive tasks, while a c7g.8xlarge instance is significantly more expensive but is a powerhouse in terms of performance.

EC2 Pricing Options

On top of the variety of instance types, EC2 offers several pricing options to better adjust to different workload requirements.

On Demand

When we talk about EC2, we're usually referring to On Demand instances, which is the default pricing option. On Demand instances are billed per time that they're active, in increments of 1 second. There are no upfront charges, and no limit on how many instances you can run.

On Demand is perfect for unpredictable workloads that experience sudden spikes, or for workloads where you still haven't identified patterns in the traffic. It's usually recommended when starting out, but once you've identified how traffic behaves, it's recommended to move on to other pricing options.

Reserved Instances

With Reserved Instances, you commit to a certain usage, for example 2 m7g.large instances, over a period of 1 or 3 years. You can choose to pay the entire cost upfront, make a partial upfront payment and get billed monthly for the rest, or simply assume the commitment and get billed monthly for it. The benefit of Reserved instances is that you pay significantly less for your instances, up to 72% less than with On Demand. The drawback is that once you've assumed the commitment you continue to pay for that capacity regardless of whether you use it.

Reserved Instances come in 3 types:

  • Standard RIs: Steep discounts but lack flexibility.

  • Convertible RIs: A bit pricier but allow changing instance types during the term.

  • Scheduled RIs: Reserve instances on a schedule, like every Saturday evening.

We've explained Reserved Instances in detail in our article ELI5: What are AWS Reserved Instances and How Do They Work?

Savings Plans

Savings Plans offer a commitment-based discount similar to Reserved Instances, but with more flexibility in what you commit to. The period is the same (1 or 3 years), and so are the payment options (full upfront, partial upfront or no upfront). The main difference is in what kind of usage you commit to.

There are two types of Savings Plans:

  • AWS Compute Savings Plans: You commit to a certain compute usage, which is valid for EC2, Fargate or Lambda, instead of just EC2.

  • EC2 Instance Savings Plans: You commit to a specific EC2 instance family, and can freely change sizes within that family, for example go from an m7g.xlarge instance to two m7g.large instances.

You can find more details about Savings Plans in our article ELI5: What Are AWS Savings Plans and How Can They Save You Money?

Also, view our article AWS Savings Plan vs Reserved Instance: What's the difference?

Spot Instances

Spot Instances are instances launched on AWS's spare capacity. They can be terminated by AWS at any time, with only a 2 minute warning. For this reason, you can't use spit instances for workloads that can't tolerate interruptions. The benefit is that they're up to 90% cheaper than On Demand instances, which makes them fantastic for non-critical workloads such as batch processing.

Amazon EC2 Pricing Example

The best way to understand how pricing works for EC2 is through an example. Let's assume our application needs a baseline of 1 EC2 instance constantly running, and it needs to scale to 2 instances for an average of 3 hours every day, and to 3 instances for an average of 1 hour every day:

  • For 20 hours a day, we need 1 EC2 instance.

  • For 3 hours a day, we need 2 EC2 instances.

  • For 1 hour a day, we need 3 EC2 instances.

Let's start with a general purpose instance, m7g.large with 2 vCPUs and 8 GB of memory. The On Demand price is $0.0816 per hour, so our costs per month are:

(20 * 1 * $0.0816 + 3 * 2 * $0.0816 + 1 * 3 * $0.0816) * 30 = $70.992/month

We're confident that our baseline of 1 instance will remain the same for 1 year, but the scaling patterns may change. So, we can explore buying a Reserved Instance or a Savings Plan for 1 year. Let's assume we don't want to pay any upfront, and run some numbers:

  • With a Compute Savings Plan, the price per hour drops to $0.0599

  • With an EC2 Savings Plan, the price per hour drops to $0.054

  • With a Standard Reserved Instance, the price per hour drops to $0.054

  • With a Convertible Reserved Instance, the price per hour drops to $0.060

It would be a good decision to purchase an EC2 Savings Plan or a Standard Reserved Instance. If you want to understand the difference, read AWS Savings Plan vs Reserved Instance: What's the difference?

Let's assume we purchase one of those, and run the numbers again:

(20 * 1 * $0.054 + 3 * 2 * $0.0816 + 1 * 3 * $0.0816) * 30 = $54.432/month

We're saving $16.56/month, which is 23% of our EC2 costs!

With Pump, our advanced AI performs these types of calculations and many more, and automatically purchases the best options for your use case. This way, you can save up to 60% on your AWS bill, in a completely automated way, and for $0 fees to you.

How to optimize Amazon EC2 costs

For most workloads, EC2 is the largest component of your AWS bill, so it's the one that should be targeted first for cost optimization. Here are some ways to optimize EC2 costs.

Rightsize Instances and Monitor Usage

AWS offers tools like Cost Explorer and Trusted Advisor that can help identify instances that are overprovisioned. Rightsizing means resizing those instances so you don't pay for capacity you don't need.

View here how to use AWS Cost Explorer to understand AWS costs.

Use The Right Pricing Option

Non-critical processes or workloads that can handle interruptions can be run on Spot Instances for a significantly lower price. Workloads with steady traffic should use Reserved Instances or Savings Plans to reduce costs. In workloads with traffic spikes, you can identify a baseline level of usage, purchase RIs or Savings Plans to cover that, and handle the spikes with On Demand instances.

Delete Orphaned Resources

When building fast, we often forget to delete a resource here and there. A single resource usually doesn't amount to much, but they can accumulate over time, and nullify all your savings efforts. These could be instances you forgot to terminate, or even forgotten EBS snapshots, old AMIs, or detached EBS volumes. You can use Cost Explorer to find these resources.

Use Pump to Automate AWS Savings

Pump uses AI to identify the most optimal pricing options for EC2 instances, and through group buying purchases the most optimal combinations of Reserved Instances and Savings Plans, leading to 60% savings in your AWS bill. It's entirely free to you, works in minutes, and doesn't require any engineering work. Furthermore, Pump is not limited to Amazon EC2, it also works on 11 other AWS services. This way, we enable startups to achieve AWS savings like big tech, without the engineering hours, and without paying a premium for those savings.

Conclusion

Amazon EC2 is one of the core AWS resources, which lets you launch applications in the cloud in minutes. On Demand instances are the default pricing option, and while it's the easiest to understand, it's not the most optimal. Understanding your workload needs and choosing the right option can lead to significant savings in your Amazon EC2 bill. You can use Pump to automatically save up to 60% on your AWS bill, in minutes, with no engineering work needed, and for free.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.