Three Ways to Cut Your EC2 Costs with Hands-on Labs

Moving to the cloud offers businesses many advantages over managing their own infrastructure. Cost savings is the primary benefit for companies that make the leap to the cloud. However, there are still many opportunities for cutting costs even after the initial migration. If unchecked, these missed opportunities could silently be costing your business money that is better spent elsewhere. Periodically reviewing your cloud usage is a great way to spot these opportunities for additional savings. In this post, we’ll show you three ways to cut your EC2 costs on Amazon Web Services (AWS) by exploring cost optimizing techniques available for their core compute service: Elastic Compute Cloud (EC2).

What is EC2?

Elastic Compute Cloud (EC2) provides infrastructure as a service (IaaS). It allows users to launch virtual machines known as “instances” that can be used to perform any kind of function that your business requires without worrying about servers, networking, and other hardware. With EC2, you can create, launch, and terminate these instances as needed and only pay for what you use. You have full control over the geographical location where the instances are provisioned, and you can take advantage of resiliency by deploying into different availability zones within each of the regions.

Pricing models

Many AWS users are familiar with the free tier, which allows you to use several services for free with some restrictions in your first year. In EC2, the popular t2.micro instance type is eligible for free tier use. But what about after your free tier eligibility runs out or when you need more powerful instances? EC2 provides several pricing models, each with their own sweet spots. Let’s take a look.

On-Demand

A popular choice in AWS, on-demand pricing provides the most flexibility in launching instances as you please. This model is best suited for unpredictable workloads that can’t be interrupted, and for early development and prototyping. On-demand instances are charged by the hour, rounded up to the nearest hour. This implies that if you terminate and launch an instance multiple times in a single hour, you will be billed for multiple hours. You also pay the price for the freedom of launching instances without any commitment. On-demand pricing is the most expensive option for EC2 in most situations.

Reserved

When you have established a steady-state or when you know your EC2 usage requirements in advance, you should consider using reserved instances. Depending on the configuration, reserved instances can save you up to 75% versus on-demand pricing. This pricing model locks you in for a one- or three-year contract with payment upfront, partially upfront, or no upfront. If you have predictable recurring demand patterns, you can make use of scheduled reserved instances, which reserve capacity only when you need it. The contracts come in standard and convertible flavors depending on how flexible you need to be for switching instance families, operating systems, etc.
If you think that you might end up having buyer’s remorse after locking in a reserved instance, there are a few things that you should know:

  • You are allowed to change availability zone, instance size (for Linux OSes), and networking type for all reserved instance contracts.
  • You can sell your unused standard reserved instance contracts if you no longer need them. The Reserved Instance Marketplace is provided by AWS for connecting buyers and sellers for third-party reserved instance contracts. The contracts will often be for a shorter duration than the standard one- or three-year contract and for a lower price.
  • You can continue to use your reserved instance while it is for sale in the marketplace. If a reserved instance contract sells while in use, you will be charged at the on-demand price.

Spot Market

Spot instances offer the potential of saving 90% over on-demand instances but come with some unique caveats. The price of spot instances is market-driven. This means that the demand for instances within AWS regions and availability zones determine the price. You submit bids for instances and as long as the bid is above the current spot price, your bid will be fulfilled. However, market conditions can change in an instant. Your instance can be terminated, potentially without any warning, once your bid is surpassed by the market price. If this is the case, you won’t be charged for the partial hour in which your instance was terminated due to increases in market price. The image below illustrates the fluctuations in spot prices across different availability zones in the us-west-2 region:
EC2 spot market price fluctuations
There are a few more ways to bid on instances instead of the single instance bid described. You can bid on groups of spot instances using spot fleets. Spot fleet requests provide a convenient way to submit multiple spot instance bids at once. Your spot fleet request may be fully, partially, or not fulfilled at all depending on the market conditions and your spot fleet request.

You can also specify an allocation strategy as part of your spot fleet request. Two allocation strategies are currently supported: lowest price and diversified. Lowest price will fulfill the request in a way that minimizes your costs. Diversified adds more concern to your application availability. It will attempt to balance instances across requested instance types and availability zones instead of only considering cost.

Spot blocks are another way to request spot instances. Spot blocks allow you to make reservations of a fixed duration between one and six hours regardless of how the spot market price fluctuates after your request is fulfilled. This provides a balance between cost savings using the spot market and ensuring your instance will not be terminated for a set amount of time. With spot blocks, you can expect to save around 30% to 45% compared to on-demand pricing. But beware. While rare, it is possible for spot block instances to be terminated in certain circumstances. If there is a large enough increase in demand for the instance type, AWS can terminate the instance but would provide a two-minute warning.

You may be able to tolerate unprompted termination in many situations. You can also make use of strategies to avoid having your instances terminated. Our new Cloud Academy lab Using EC2 Spot Instances teaches you the ins and outs of using spot instances hands-on. As the lab demonstrates, spot pricing can be combined with the next cost saving opportunity: auto-scaling.
EC2 Instances Hands On Lab

Scaling to meet demand

When a new service gets developed, the load profile for it is unknown — this is a common scenario. To develop the service quickly, a couple of EC2 instances are spun up to provide high availability for the service. Before long, the developers get busier and the service becomes more popular.

To handle the load, larger instances are used or more instances get added. From a cost perspective, this is not optimal because the load is very likely to fluctuate over different days of the week and different hours of the day. You could be paying to service peak load 24/7 when in reality your peak loads happen at various intervals—and not 24/7. Avoiding this kind of operational inefficiency is probably one reason why you moved to the cloud in the first place.

AWS provides auto-scaling to meet the dynamic demands of your applications with minimal operational overhead. When there is a large load, auto-scaling will launch more instances and vice versa for when load decreases. This can lead to significant savings when using on-demand or spot instances. This type of auto-scaling is called dynamic scaling.

Here is another scenario. Let’s say that there is a delay between when the change in load is detected, when the instance launches, and when the instance is available for use. This can be unsatisfactory for handling spikes in load. If you want to be more proactive but still save on costs, you can use scheduled scaling. With scheduled scaling, you can choose the time and days that you would like to add more instances so you are ready but also not paying for off-peak hours.

There is no additional charge to use auto-scaling. Charges are simply for the underlying instance hours according to the pricing model that is in effect. Each of the previously described pricing models are available here.

Enterprise users

If your company has enterprise licenses, for example, Windows, SQL Servers, or Red Hat Enterprise Linux, you can bring them to the AWS cloud and free yourself from the hardware and maintenance costs by using EC2 Dedicated Hosts.

Dedicated Hosts provide you with a physical server that is not shared with other cloud customers. This is not to be confused with Dedicated Instances, which offer the same benefit. In addition to isolation from other customers, Dedicated Hosts provide more control over how instances are placed on the host. For example, if you restart a Dedicated Instance, it could end up on a different host, which would not play well with a license attached to a specific host.

Dedicated Hosts can be charged using on-demand or reserved pricing. If you only need the security of being isolated from other customers, you can use Dedicated Instances that can be charged using all three pricing models discussed earlier, giving you more opportunities to save. AWS provides tables that make it easy for you to compare Dedicated Instance pricing options and Dedicated Host pricing options.

Microsoft
For Microsoft users, in particular, you can consider additional cost saving opportunities. If you prefer to have AWS handle the Microsoft licenses for EC2 instances, that’s no problem. But keep in mind that the same instance running Windows will cost twice as much as if the instance were running Linux, and even more if running SQL Server on top. With SQL Server 2017 running on Linux and Microsoft .NET Core allowing applications to run on Linux, now is as good a time as any to consider the question of operating system dependence and how it impacts your bottom line.

Next steps

Remember, cost savings do not end after cloud migration. There are many opportunities to optimize costs throughout the lifetime of your cloud operations. If you’re looking to reduce your current EC2 bill, try these three options:

  1. Consider your pricing model options. Spot instances offer up to 90% savings over on-demand while reserved instances offer up to 75% savings.
  2. Make use of auto-scaling to automatically allocate just enough EC2 instances.
  3. Think creatively about your options for cutting back on enterprise license costs that are included in your EC2 bill.

These options all play well with one another and can work together to give you the most value in the cloud.
To get started with implementing savings on EC2, our hands-on labs for spot instances and auto-scaling will guide you every step of the way.

  • Using EC2 Spot Instances will show you the ins and outs of using EC2 spot instances in AWS. We’ll cover everything from a one-time spot instance request to strategies for dealing with unprompted instance termination and maintaining auto scaling spot fleets.
  • For auto-scaling, start with our hands-on lab Working with Amazon EC2 Auto Scaling Groups to learn the basics of auto-scaling in AWS, then move on to Creating Your First Auto Scaling Group to scale the Amazon EC2 capacity up or down automatically according to the defined conditions.

Next, stay tuned for our upcoming Cloud Academy course devoted entirely to optimizing your costs in the cloud.

Avatar

Written by

Logan Rakai

Logan has been involved in software development and research for over ten years, including four years in the cloud. At Cloud Academy, he is adding to the library of hands-on labs.


Related Posts

Avatar
Stuart Scott
— October 16, 2019

AWS Security: Bastion Host, NAT instances and VPC Peering

Effective security requires close control over your data and resources. Bastion hosts, NAT instances, and VPC peering can help you secure your AWS infrastructure. Welcome to part four of my AWS Security overview. In part three, we looked at network security at the subnet level. This ti...

Read more
  • AWS
Avatar
Sudhi Seshachala
— October 9, 2019

Top 13 Amazon Virtual Private Cloud (VPC) Best Practices

Amazon Virtual Private Cloud (VPC) brings a host of advantages to the table, including static private IP addresses, Elastic Network Interfaces, secure bastion host setup, DHCP options, Advanced Network Access Control, predictable internal IP ranges, VPN connectivity, movement of interna...

Read more
  • AWS
  • best practices
  • VPC
Avatar
Stuart Scott
— October 2, 2019

Big Changes to the AWS Certification Exams

With AWS re:Invent 2019 just around the corner, we can expect some early announcements to trickle through with upcoming features and services. However, AWS has just announced some big changes to their certification exams. So what’s changing and what’s new? There is a brand NEW ...

Read more
  • AWS
  • Certifications
Alisha Reyes
Alisha Reyes
— October 1, 2019

New on Cloud Academy: ITIL® 4, Microsoft 365 Tenant, Jenkins, TOGAF® 9.1, and more

At Cloud Academy, we're always striving to make improvements to our training platform. Based on your feedback, we released some new features to help make it easier for you to continue studying. These new features allow you to: Remove content from “Continue Studying” section Disc...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
  • ITIL® 4
  • Jenkins
  • Microsoft 365 Tenant
  • New content
  • Product Feature
  • Python programming
  • TOGAF® 9.1
Avatar
Stuart Scott
— September 27, 2019

AWS Security Groups: Instance Level Security

Instance security requires that you fully understand AWS security groups, along with patching responsibility, key pairs, and various tenancy options. As a precursor to this post, you should have a thorough understanding of the AWS Shared Responsibility Model before moving onto discussi...

Read more
  • AWS
  • instance security
  • Security
  • security groups
Avatar
Jeremy Cook
— September 17, 2019

Cloud Migration Risks & Benefits

If you’re like most businesses, you already have at least one workload running in the cloud. However, that doesn’t mean that cloud migration is right for everyone. While cloud environments are generally scalable, reliable, and highly available, those won’t be the only considerations dri...

Read more
  • AWS
  • Azure
  • Cloud Migration
Joe Nemer
Joe Nemer
— September 12, 2019

Real-Time Application Monitoring with Amazon Kinesis

Amazon Kinesis is a real-time data streaming service that makes it easy to collect, process, and analyze data so you can get quick insights and react as fast as possible to new information.  With Amazon Kinesis you can ingest real-time data such as application logs, website clickstre...

Read more
  • amazon kinesis
  • AWS
  • Stream Analytics
  • Streaming data
Joe Nemer
Joe Nemer
— September 6, 2019

Google Cloud Functions vs. AWS Lambda: The Fight for Serverless Cloud Domination

Serverless computing: What is it and why is it important? A quick background The general concept of serverless computing was introduced to the market by Amazon Web Services (AWS) around 2014 with the release of AWS Lambda. As we know, cloud computing has made it possible for users to ...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
Joe Nemer
Joe Nemer
— September 3, 2019

Google Vision vs. Amazon Rekognition: A Vendor-Neutral Comparison

Google Cloud Vision and Amazon Rekognition offer a broad spectrum of solutions, some of which are comparable in terms of functional details, quality, performance, and costs. This post is a fact-based comparative analysis on Google Vision vs. Amazon Rekognition and will focus on the tech...

Read more
  • Amazon Rekognition
  • AWS
  • Google Cloud Platform
  • Google Vision
Alisha Reyes
Alisha Reyes
— August 30, 2019

New on Cloud Academy: CISSP, AWS, Azure, & DevOps Labs, Python for Beginners, and more…

As Hurricane Dorian intensifies, it looks like Floridians across the entire state might have to hunker down for another big one. If you've gone through a hurricane, you know that preparing for one is no joke. You'll need a survival kit with plenty of water, flashlights, batteries, and n...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
  • New content
  • Product Feature
  • Python programming
Joe Nemer
Joe Nemer
— August 27, 2019

Amazon Route 53: Why You Should Consider DNS Migration

What Amazon Route 53 brings to the DNS table Amazon Route 53 is a highly available and scalable Domain Name System (DNS) service offered by AWS. It is named by the TCP or UDP port 53, which is where DNS server requests are addressed. Like any DNS service, Route 53 handles domain regist...

Read more
  • Amazon
  • AWS
  • Cloud Migration
  • DNS
  • Route 53
Alisha Reyes
Alisha Reyes
— August 22, 2019

How to Unlock Complimentary Access to Cloud Academy

Are you looking to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Cloud Security, Python, Java, or another technical skill? Then you'll want to mark your calendars for August 23, 2019. Starting Friday at 12:00 a.m. PDT (3:00 a.m. EDT), Cloud Academy is offering c...

Read more
  • AWS
  • Azure
  • cloud academy content
  • complimentary access
  • GCP
  • on the house