Reducing Operational Cost With AWS

There are two types of expenses - capex and opex. Capex (Capital Expense) includes things like buying a server and infrastructure of data centers; and opex is the operational cost. Cloud Service Provider like AWS and Azure have nearly eliminated the capital expense for organizations, they only have to pay for the operational expenses. In this article, I will cover ways to reduce operational expenses.
To reduce opex, one has to identify their own business needs. Pay only for what you need and when you need it. For eg, your production servers are running 24 hours a day and will run for months. In this scenario, going for On-demand EC2 and paying for every hour is not a good option.
 
AWS offers 4 categories of EC2,
  • On-Demand
  • Reserved
  • Spot Instance
  • Dedicated

On-demand

  1.  Pay per hour.
  2.  No commitments, can be terminated when not in need.
  3. These are suitable for spiky, variable load applications. Also suitable for testing, staging environment.

Reserved Instances

  1. For predictable workloads, when we know we will need an instance for a year or more, reserving an instance is a better option.
  2. Reserved Instance is at 50-70 % lesser cost than on-demand.
  3. An instance can be reserved for 1 or 3 years.
  4. You can pay all upfront, partial upfront, or nothing upfront.
Let us understand by a scenario,
 
Suppose you are running a t2.large instance for your production environment. Let's compare the price you pay for On-demand and Reserved instances.
 
 
Approximate values
 
Currently Running Cost
12 Month Cost-Reserved Instance
Instance Type
On Demand
No Upfront
Partial Upfront
Full Upfront
t2.large
$812.92
$503.70
$480.02
$470.00
 
This is the cost of running a t2.large linux instance on AWS for a year. A lot can be saved when you know, you will need this server for a year or longer.
 

Spot Instances

 
AWS always has extra servers in their data center. They always keep spare servers for unexpected demands. Instead of keeping them idle, AWS makes them available as spot instances. A spot instance is cheaper than on-demand, but it can be taken away whenever AWS needs it. These are suitable for applications that can be interrupted such as batch processing, analyses, etc. For spot instances, AWS uses a bidding mechanism.
  • Spot Price - Hourly price for spot instance
  • Maximum price per hour - Your maximum offer to pay for spot instance.
Spot price keeps on varying. Your spot instance will be with you,
  • If there is capacity available
  • The spot price is lesser than your maximum price to pay.
The spot instance is taken away,
  • If the spot price increases above your maximum price
  • AWS needs capacity back. A 2 minute warning is given before the termination

Dedicated Instances

 
When you launch an instance in AWS, by default, it runs on shared hardware. But if you want your instance to run on dedicated hardware, you should opt for a dedicated instance. A dedicated instance runs on single tenant hardware. Similarly, there is a dedicated host, where you have dedicated hardware also visibility of its placement.
 
Dedicated instances are generally used to meet compliance.
 
Looking at the above available options for the EC2, a wise decision should be made in selecting the right class to reduce the AWS bills. At least reserve your production server for 1 year, try using spot instances for analytics and processing use case. 
 
To increase efficiency, continuous cost optimization should be done. Following this, you should check,
  • Opt for reserved instances
  • Select Spot instances for flexible application (those can be interrupted)
  • Monitor Cloudwatch graphs, downsize the instance or database if underutilized.
  • Use auto scaling policies.
  • Stop Dev, UAT instances during non-business hours.


Similar Articles