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 Instancesteaches 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 .

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.

Written by

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

— November 28, 2018

Two New EC2 Instance Types Announced at AWS re:Invent 2018 – Monday Night Live

Let’s look at what benefits these two new EC2 instance types offer and how these two new instances could be of benefit to you. Both of the new instance types are built on the AWS Nitro System. The AWS Nitro System improves the performance of processing in virtualized environments by...

Read more
  • AWS
  • EC2
  • re:Invent 2018
— November 21, 2018

Google Cloud Certification: Preparation and Prerequisites

Google Cloud Platform (GCP) has evolved from being a niche player to a serious competitor to Amazon Web Services and Microsoft Azure. In 2018, research firm Gartner placed Google in the Leaders quadrant in its Magic Quadrant for Cloud Infrastructure as a Service for the first time. In t...

Read more
  • AWS
  • Azure
  • Google Cloud
Khash Nakhostin
— November 13, 2018

Understanding AWS VPC Egress Filtering Methods

Security in AWS is governed by a shared responsibility model where both vendor and subscriber have various operational responsibilities. AWS assumes responsibility for the underlying infrastructure, hardware, virtualization layer, facilities, and staff while the subscriber organization ...

Read more
  • Aviatrix
  • AWS
  • VPC
— November 10, 2018

S3 FTP: Build a Reliable and Inexpensive FTP Server Using Amazon’s S3

Is it possible to create an S3 FTP file backup/transfer solution, minimizing associated file storage and capacity planning administration headache?FTP (File Transfer Protocol) is a fast and convenient way to transfer large files over the Internet. You might, at some point, have conf...

Read more
  • Amazon S3
  • AWS
— October 18, 2018

Microservices Architecture: Advantages and Drawbacks

Microservices are a way of breaking large software projects into loosely coupled modules, which communicate with each other through simple Application Programming Interfaces (APIs).Microservices have become increasingly popular over the past few years. The modular architectural style,...

Read more
  • AWS
  • Microservices
— October 2, 2018

What Are Best Practices for Tagging AWS Resources?

There are many use cases for tags, but what are the best practices for tagging AWS resources? In order for your organization to effectively manage resources (and your monthly AWS bill), you need to implement and adopt a thoughtful tagging strategy that makes sense for your business. The...

Read more
  • AWS
  • cost optimization
— September 26, 2018

How to Optimize Amazon S3 Performance

Amazon S3 is the most common storage options for many organizations, being object storage it is used for a wide variety of data types, from the smallest objects to huge datasets. All in all, Amazon S3 is a great service to store a wide scope of data types in a highly available and resil...

Read more
  • Amazon S3
  • AWS
— September 18, 2018

How to Optimize Cloud Costs with Spot Instances: New on Cloud Academy

One of the main promises of cloud computing is access to nearly endless capacity. However, it doesn’t come cheap. With the introduction of Spot Instances for Amazon Web Services’ Elastic Compute Cloud (AWS EC2) in 2009, spot instances have been a way for major cloud providers to sell sp...

Read more
  • AWS
  • Azure
  • Google Cloud
— August 23, 2018

What are the Benefits of Machine Learning in the Cloud?

A Comparison of Machine Learning Services on AWS, Azure, and Google CloudArtificial intelligence and machine learning are steadily making their way into enterprise applications in areas such as customer support, fraud detection, and business intelligence. There is every reason to beli...

Read more
  • AWS
  • Azure
  • Google Cloud
  • Machine Learning
— August 17, 2018

How to Use AWS CLI

The AWS Command Line Interface (CLI) is for managing your AWS services from a terminal session on your own client, allowing you to control and configure multiple AWS services.So you’ve been using AWS for awhile and finally feel comfortable clicking your way through all the services....

Read more
  • AWS
Albert Qian
— August 9, 2018

AWS Summit Chicago: New AWS Features Announced

Thousands of cloud practitioners descended on Chicago’s McCormick Place West last week to hear the latest updates around Amazon Web Services (AWS). While a typical hot and humid summer made its presence known outside, attendees inside basked in the comfort of air conditioning to hone th...

Read more
  • AWS
  • AWS Summits
— August 8, 2018

From Monolith to Serverless – The Evolving Cloudscape of Compute

Containers can help fragment monoliths into logical, easier to use workloads. The AWS Summit New York was held on July 17 and Cloud Academy sponsored my trip to the event. As someone who covers enterprise cloud technologies and services, the recent Amazon Web Services event was an insig...

Read more
  • AWS
  • AWS Summits
  • Containers
  • DevOps
  • serverless