AWS Basics: How AWS EC2 Pricing Works + Examples

AWS Basics: How AWS EC2 Pricing Works + Examples

Price is one of the biggest problems people have with AWS. 

And that’s pretty understandable. 

Some AWS services are expensive and the data transfer costs aren’t easy to understand.

But for the most part, people rack up huge bills because they never learned how AWS pricing works. That’s why it’s important to get a good grasp on the fundamentals before committing lots of money to any service.

Today, we’re talking about pricing in the context of the most commonly used AWS service - Elastic Compute Cloud (EC2)

According to cloud economist Corey Quinn, EC2 is almost always the biggest spend category. Put simply, if you don’t know how EC2 pricing works, you’re going to have a bad time with AWS.

Let’s get started.

AWS Pricing Fundamentals

Before diving into specific services, you first need to understand the fundamentals behind AWS’s pricing.

Fortunately, they’re pretty logical and straightforward. 

In short, there are three main AWS pricing principles:

  • On-demand payments
  • Reserving capacity
  • Volume-based discounts
No alt text provided for this image

Source - AWS pricing page

On-Demand Pricing 

This is what people associate with the cloud. On-demand lets you use services and pay only for the resources you consume. 

With AWS, you pay for this model by the hour or by the second.

On-demand saves you from the dreaded business of planning ahead and actually thinking about how your infra might look a year from now.

  • Advantages: Flexibility, no commitments and ease of use
  • Disadvantages: The most expensive pricing model
  • Best use cases: Testing, small or unpredictable workloads

While cloud providers sell the dream of on-demand usage, in reality, that’s not a viable model in the long-run. Pay-as-you-go is incredibly expensive, no matter how you look at it.

As soon as you get comfortable with AWS, you should think about reserving capacity to save money.

Reserving Capacity

Some AWS services, including EC2, can be reserved in advance. This means that you commit to a specific time frame in exchange for a discount.

Now, just because you reserve a service for a year doesn’t mean you have to pay for it right away. You can do so if you want, but you can also pay a partial upfront fee and still get a small discount.

No alt text provided for this image

Source - AWS pricing page

  • Advantages: Budget predictability, discounts 
  • Disadvantages: Lack of flexibility, requires planning
  • Best use cases: Well-established, predictable workloads

Reserving capacity might not be as exciting as on-demand, but it’s way more viable. As your business grows, this model lets you plan your budget, get a discount and minimize risk at the same time.

Volume-Based Discounts 

This final point is also pretty logical. As your usage increases, you get discounts based on the volume you run through AWS.

S3 is a great example of this principle. Since it’s a tiered service, the more you use it, the less you pay per GB. 

Put simply, as your infrastructure grows, you can benefit from AWS’s massive economies of scale. Not much more to say here.

AWS EC2 Pricing Examples

As I already said, EC2 makes up most of the costs in a typical AWS account. That’s why it's important to get familiar with EC2 pricing first.

There are five ways to pay for EC2 instances:

  • On-Demand
  • Savings Plans
  • Reserved Instances
  • Spot Instances
  • Dedicated Hosts

For this article, I’ve chosen a random, Compute Optimized instance - c5n.4xlarge in the US East (Ohio) region.  

No alt text provided for this image

We’ll do that through the EC2 calculator (without changing anything) and see how much we pay with each of the five options.

But first, let’s quickly look at the EC2 free tier.

EC2 Free Tier

You can use up to 750 hours of Linux or Windows t2.micro instances for one year for free.

Here are the t2. micro instance specs:

No alt text provided for this image

Source - EC2 instance types page

As you can see, it’s not something amazing, but you can still do a lot with it. If you’re just learning AWS, you can easily work on tons of stuff without crossing the limit.

Just remember: EC2 might have a free tier, but some other services don’t. If you use a combination of services, always check their specific pricing pages.

Also, data transfer prices still apply even within the free tier.

On-Demand

As I already said, in general the on-demand is expensive. EC2 instances aren’t an exception to this rule.

Here’s how much we’ll have to pay for our c5n.4xlarge instance in the US East (Ohio) region if we use it on-demand for a year:

No alt text provided for this image

Source - EC2 calculator

Again, this is without changing any of the default settings.

Savings Plans

Savings Plans are a relatively new concept. They let you commit to a 1 or 3 year level of compute usage, measured in $ per hour.

That way, you still get predictability without selecting specific instance types, i.e. you keep a lot of flexibility.

Here’s how our instance pricing looks after 1-year with Savings Plans without an upfront payment:

No alt text provided for this image

Source - EC2 calculator

If we decide to pay upfront, the monthly discount gets much larger:

No alt text provided for this image

Source - EC2 calculator

For most small companies, Savings Plans are the way to go. They’re easy to work with and provide a unique combination of predictability and flexibility.

Reserved Instances

Reserved Instances are similar to Savings Plans with one key difference - you reserve a specific instance (like c5n.4xlarge), not a compute usage level.

Obviously both provide similar benefits, but Reserved Instances are a bit trickier to get right. You have to choose a specific instance, which can be time-consuming since there are many options.

Also, you pay for the full reserved capacity, even if you utilize only a part of it.

Here’s our reserved instance pricing for 1-year with no upfront payment:

No alt text provided for this image

Source - EC2 calculator

And with a partial upfront payment:

No alt text provided for this image

Source - EC2 calculator

As you can see, the prices are nearly identical to the Savings Plans example.

Also, with Reserved Instances, you have the option to reserve convertible instances. These instances cost more because they allow you to switch between instance types during the reserved period.

Spot Instances

Spot Instances provide the largest possible discount and are the hardest to manage. Essentially, they are a way for AWS to make money from their unused computing capacity.

You can rent these unused resources for up to 90% off the on-demand price. The catch is that AWS can terminate your spot instance with a 2-minute notice if someone comes along and pays full price for it.

Working with these instances takes more skill, especially at scale. However, there are entire businesses that run on spot only

Here’s how much we’d pay for our instance, based on historical data about its average discount:

No alt text provided for this image


Source - EC2 calculator

As you can see it’s much cheaper than anything else.

If you’re just starting out, don’t use Spot Instances for business-critical workloads, but if you want to experiment, Spot Instances are your best friend. 

Dedicated Hosts

I won’t go in-depth on this final option since few people actually use it. Dedicated Hosts are physical servers that you essentially rent from AWS. 

They stay in Amazon’s data centers and AWS takes care of cleaning, maintaining and updating the hardware.

As a general rule, the other models separate customers only on the software level. Physical machines are usually shared between multiple users.

That’s why Dedicated Hosts are incredibly expensive and are rarely used. For example, companies rent dedicated physical machines because of regulatory/compliance concerns.

Final Thoughts

AWS pricing can get a lot more complex than what we just covered. But if you learn the basics well, everything else gets easier.

If you’re eager for something more advanced, I’d recommend diving deep into AWS data transfer costs. It’s a complicated topic that few people understand in-depth.

Finally, if you want to align your cloud spend and performance with your business, don’t hesitate to drop us a line.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了