Table Of Contents
1. Choosing The Right Instance Type 2. Understanding The Differences Between AWS Pricing Models 3. Leveraging Tools To Cut Down Hourly Costs

Amazon Web Services (AWS) has been the leader in cloud computing for more than ten years. Despite a decade of extensive innovation, no other resource encapsulates the principles of the cloud more than one of their flagship services, Elastic Cloud Computing, also known as EC2.

Through EC2, AWS is able to offer flexible and scalable virtual infrastructure that can be ‘rented’ to run applications and workloads.

Given its extreme popularity, most of us are already quite adept at the usefulness of Elastic Cloud Computing and the purposes it serves, but where many of us can improve is around the patterns and habits we employ to ensure that our workloads are running as efficiently, and cost-effectively, as possible.

In order to build a strategy that optimizes EC2 cost efficiency, we first need to understand how EC2 cost is calculated.

What you pay is determined by a combination of factors, which include the instance type, region, pricing model (think Reserved Instances, Spot Instances, etc.), and additional services that are used in conjunction with your compute (think storage, load balancers, and data transfer)

Once we understand what makes up the monthly bill, we can begin constructing a strategy that focuses on those specific factors. Let’s take a look at some specific steps we can take to optimize our efficiency and cost:

1. Choosing The Right Instance Type

AWS offers a number of different instance types that cater to different kinds of workloads. Selecting the right kind of instance type is critical to ensuring cost efficiency.

As leaders within our respective organizations, we tend to have an intimate understanding of how our applications work. Having that knowledge allows us to know what our app needs in order to function properly.

Is our app CPU intensive? Is it memory intensive? Does it need a mix of both?

Specific instance types are meant for specific needs, but when it comes to keeping costs low, we must be able to understand and spot where underutilization and overprovisioning is occurring.

One of the more effective ways to spot these inefficiencies is by making use of monitoring tools. As our workloads become more complex, so do our monitoring needs.

However, even if our monitoring tool of choice isn’t yet tweaked to the specific needs of our app, we can still monitor basic metrics to begin generating historical data to identify what our workload is utilizing, and comparing that to what our instance type currently offers.

With that information in hand, we’re able to make a more educated assumption on future trends, as well as determine if we can make the move to a smaller instance type (thus saving money!)

We also suggest getting acclimated to AWS’ Instance Type Cost Matrix. This is a spreadsheet that incorporates all available instance types, along with a breakdown of what kind of workload they should be used for.

If you’re not quite sure what the cost of two different instance families is, you can use a third-party tool, like CloudZero Advisor, to get a breakdown of what each would cost you on an hourly basis.

Table

CloudZero Advisor is a completely free tool (no login required), and a simple way to compare pricing on AWS services like EC2, RDS, ElastiCache, and more.

It’s important to remember that the same instance type can have a different cost depending on the region in which you’re deploying, so make sure that you take that into account!

finops-automation-series-thumbnails

2. Understanding The Differences Between AWS Pricing Models

By far, one of the largest cost-saving strategies that can be employed is the use of Spot and Reserved Instances. While you may have heard the term before, it’s important to understand how these are different than On-Demand Instances, which is the default model that AWS uses.

When we use the terms On-Demand, Spot, and Reserved Instances, we’re referencing the different pricing models that AWS uses. Each of these caters to different use cases and offers varying availability and cost savings. It’s imperative to understand the nuances between the two to ensure that you’re making the right decision.

On-Demand Instances

  • Pricing is going to be predictable. AWS calls this ‘pay-as-you-go’, meaning that your cost is calculated by how long the instance is running, whether that be by the hour or the second, and the rate will always be the same.
  • Availability is guaranteed. Once you launch your instance, the instance will always be available to serve your application for as long as it’s needed.
  • Consistent performance is also guaranteed, meaning that you can safely predict application performance to ensure that high-traffic times, like new releases and sales, do not impact the customer experience.

Spot Instances

  • Pricing is less predictable but guaranteed to be cheaper than On-Demand. The cost savings on Spot Instances can sometimes be as drastic as 90% less than On-Demand.
  • Due to the drastic savings, availability is not guaranteed. Spot Instances are only available when there are spare resources in AWS data centers. This means that if those resources end up being needed by either On-Demand or Reserved Instances, your Spot Instances will be terminated with no notice.
  • Given how unreliable Spot Instances can be, the workloads that run on these need to account for that. Spot Instances are great for any workload that can handle being interrupted and can still come back up cleanly. Think batch processes, unimportant cronjobs, web crawling and scraping — essentially anything that is not imperative to the customer experience.

Reserved Instances

  • Pricing will be cheaper than On-Demand, but not quite as cheap as Spot. You can safely predict a cost savings of at least 30%, and as high as 75%, compared to On-Demand.
  • In order to leverage RIs, you have to be willing to commit to a contractual agreement. These are usually either one or three years.
  • Unlike Spot instances, RIs do guarantee availability, even during peak times.

To summarize: For mission-critical workloads that are short-term, opt for On-Demand Instances. For long-term workloads that need predictability, opt for Reserved Instances. Finally, for workloads that can sustain interruptions, look to use Spot instances.

3. Leveraging Tools To Cut Down Hourly Costs

Despite Reserved Instances having payment options that can completely remove the hourly rate, most customers will opt for a model that still takes the compute uptime into account.

With this in mind, leveraging tools that will automate the start-up and shutdown of EC2 instances, based on a schedule, will go a long way in furthering your cost optimization.

The AWS EC2 Instance Scheduler is a tool that I’ve used extensively. Behind the scenes, it uses a combination of resources, like Cloudformation, Lambda, and DynamoDB, to provide the user with an easy-to-manage interface to create a schedule.

Once created, AWS will automate the starting and stopping of EC2 Instances to match what is defined. Pricing models that charge hourly only charge if the instance is up and running. By shutting down instances during off-hours, significant cost savings can be incurred.

In conclusion, AWS offers an incredibly vast array of services that can be leveraged to successfully operate and host our workloads. However, that flexibility leaves us with a crucial need to have a deep understanding of how costs are calculated and what we can do to run our applications as efficiently as possible.

By following the above suggestions — choosing the right instance type, determining the appropriate pricing model, and leveraging tools to make sure we’re not incurring unnecessary costs during slower times — we’re able to strike a balance between performance and cost.

As engineers, administrators, and decision-makers, the responsibility lies on our shoulders to continuously assess the needs of our workloads and adjust our strategies accordingly.

The Modern Guide To Managing Cloud Costs

Traditional cost management is broken. Here's how to fix it.

Modern Cost Management Guide