AWS pricing and Cost Optimization: Basic Guide

Omkar Tirodkar

Omkar Tirodkar

11 January 2019

Amazon Web Services (AWS) helps us to move faster, reduce costs through a broad set of global compute, storage, database, analytics, application, and deployment services. One of the main benefits of AW services is the ability it gives us to optimize costs to match our needs, even after our needs change. In AWS you are paying for the services you use. Most of the time you don’t have to make any upfront payment. It is helpful for the volatile demands of the customers. AWS offers three payment models:

  • Pay-as-you-go: AWS offers us a pay-as-you-go approach for pricing for over most of the cloud services. In this option, we can pay only for the individual services we need, for as long as we use them, and without requiring long-term contracts or complex licensing. We have to pay for the services you consume, and once we stop using them, there are no additional costs or termination fees. This allows us to easily adapt to changing requirements without overcommitting budgets and improving your responsiveness to changes.
  • Save when you reserve: For certain services like EC2 and RDS, we can reserve the instances. With Reserved Instances, we can save up to 75% over the same on-demand capacity. When we purchase the Reserved Instances, the larger the upfront payment, the greater the discount.
  • Payless by using more: In this option, we can get volume-based discounts and realize important savings as our usage increases. For some services like S3, the more we use, the less you pay per GB.

AWS services do not have complex dependencies or licensing requirements, so we can get exactly what we need to build innovative, cost-effective solutions as per our need.

Fundamentals of AWS pricing

There are three fundamental components for the cost AWS:

  • Compute
  • Storage
  • Outbound data transfer

These characteristics vary, depending on the AWS product and pricing model we choose. The outbound data transfer is aggregated across services and then charged at the outbound data transfer rate. This charge appears on the monthly statement of an AWS Data Transfer Out. It follows Payless by using more model. The more data, we transfer, the less we have to pay per GB. For compute resources, we pay hourly for the time we launch a resource until the time we terminate the instance. For data storage and transfer, we are typically paying per GB. In most of the cases AWs does not charge for the following:

  • Inbound data transfer
  • Data transfer between the AWS services within the same region

AWS Free Tier

It is offered by AWS to the new customers so that they can get hands-on experience with the AWS platform, products, and services. The free tier from AWS has two kinds of free services:

  • Introductory
  • Non-Expiring

Introductory

The Introductory free tier is given to all AWS customers immediately after they sign up. It is valid for 12 months from the day they register on AWS. The following services and their features that are included in the free tier:

  • Amazon EC2
    • 750 hours of free Windows or Linux t2.micro compute instance usage per month
    • We can either run 1 instance for 750 hours for one month or two instances for half a month
  • Amazon S3
    • 5GB of standard storage
    • 20,000 Get requests
    • 2,000 Put requests
  • Amazon RDS
    • 750 hours of free db.t2.micro compute instances
    • 20 GB of DB storage for any combination of SSD or Magnetic
    • 20GB of backups with RDS Magnetic storage
    • 10,000,000 IOs
  • Amazon CloudFront
    • 50GB Data Transfer Out
    • 2,000,000 HTTP and HTTPS requests
  • Data Transfer
    • 15GB of data transfer out aggregated of all AWS services

Non-Expiring

It doesn’t expire even after 12 months. It includes the following services:

  • AWS Lambda
    • 1,000,000 free requests per month
    • 3.2 million seconds of computing time per month
  • AWS KMS
    • 20,000 free requests per month
  • Amazon SES
    • 62,000 outbound messages per month
    • 1000 inbound messages per month
  • Amazon CloudWatch
    • 10 Amazon CloudWatch custom metrics covering 1,000,000 API requests
    • 5GB log data ingestion
    • 5GB log data Archive
    • 3 Dashboards with 50 metrics each per month
  • DynamoDB
    • 25GB storage
    • 25 units read and 25 units write capacity

Cost Optimization in AWS

EC2 Instances:

In case of DEV and TEST environment, stop the instances when they are not used. It will reduce the computing charges. Reserve the instance when it is going to be used for a longer period of time.

EBS Volumes and Snapshots:

If we stop the instance the computing charges are saved, but the volume charges will remain. In order to avoid this, we can create the AMI of the instance and terminate the instance. As AMI is stored in S3, storage in S3 is cheaper than EBS volumes. Delete older snapshots (e.g. older than 30 days) as per the requirements of the project. We can automate this process by creating a lambda function and trigger this function every day at a particular time every day using Cloudwatch.

Database:

Use multi-AZ database instance for the PRODUCTION environment only. For DEV and TEST environment, use single AZ (Availability zone) database instance. Stop the instance, when it is not used. It will reduce the computing charges. reserved the instance, when it is required to be used for the long term.

Elastic IP:

Elastic IPs are charged if they are not associated with any instances. So remove the Elastic IPs which are not associated with EC2 instances.

Data Transfer:

Create VPC Endpoint between S3 bucket and VPC. It will keep the traffic within the VPC. It will suppress the data transfer costs between Amazon S3 and EC2 instances.

S3:

S3 can be used for storing log files. We can Apply Lifecycle policy for S3 which will transfer the files to the S3 glacier after a certain period of time (e.g. 30 days). AWS S3 Glacier is cheaper than S3. We can set Lifecycle policy to delete the files in S3 glacier after a certain period of time (e.g. 1 year).

Optimizing costs with reservation

Even the cloud is well suited for variable workloads and rapid deployment, many cloud-based Workloads have a more predictable pattern. For these stable applications, organizations can get significant cost savings by using Reserved Instances and other reservation models for computing and data services. Reserved Instances provide us a significant discount compared to On-Demand Instance price. For example, using Amazon EC2 Reserved Instances, you can save up to 75 percent over On-Demand instance. Note: Once the instance is reserved we can’t revert it back. Reserved Instances are charged for every hour during the term that we select, regardless of whether an instance is running or not.

 What is the Reserved Instance?

  • A Reserved Instance is actually just a reservation. No new instance will be created when we purchase a reservation.
  • If we have an existing instance, we simply purchase a reservation matching that instance type, platform, and availability zone.
  • The billing system is constantly checking at the running instances and our reservations. When the match (same type, platform, AZ) is found, instance automatically gets the lower hourly rate.

 How AWS charges Reserved Instances?

  • If the customers are using both Reserved and On-Demand instances, then Reserved Instance rates applied first to minimize costs.
  • One has to pay the low hourly usage fee for every hour in our Reserved Instance term (which means we are charged the hourly fee regardless of whether any usage has occurred during an hour).
  • When our total quantity of running instances during a given hour exceeds the number of applicable Reserved Instances we own, we will be charged the On-Demand rate. E.g if we own three Reserved Instances with the same instance attributes and region (or Availability Zone if applicable), the billing system checks each hour to see how many total instances you have running that match those parameters. If the number of instances is three or less, we will be charged for the Reserved Instance rate for each matching instance running that hour. If more than three instances are running, we will be charged for the On-Demand rate for the additional instances.

 Amazon EC2 Reserved Instances

Amazon EC2 Reserved Instances (RI) can provide a significant discount (up to 75%) compared to On-Demand instances. It also provides a capacity reservation when it is used in a specific Availability Zone.

  • Types of EC2 Reserved Instances:
    • Standard Reserved Instance: Some attributes, such as instance size, can be modified during the term; however, the instance type cannot be modified.
    • Convertible Reserved Instance: It can be exchanged during the term for another Convertible Reserved Instance with new attributes including instance family, instance type, platform, scope, or tenancy.
  • Modifying EC2 Reserved Instance
    • When our computing requirements change, we can modify Standard or Convertible Reserved Instances.
    • We can modify the following attributes in the Standard Reserved Instance.
      • Availability Zone
      • Scope: From region to AZ and vice versa
      • Instance Size: We can change the instance size of the instance. But there are some restrictions. We can only change the instance size in the same family and we can change the size such that the normalization factor of the instance will remain the same. The following table shows the normalization factor that applies to an instance type:
        Instance SizeNormalization Factor
        nano0.25
        micro0.50
        small1
        medium2
        large4
        X-Large8
        2xlarge16

        E.g We can change one t2.large instance into two t2.medium instances or four t2.small instances or eight t2.micro instances or 16 t2.nano instances. We can also combine 16 t2.nano instances or eight t2.micro instances or four t2.small instances or two t2.medium instances into one t2.large instance.

Note: We can’t combine all the reserved small instances into a large instance, even if the normalization factor condition is satisfied. To combine the smaller Reserved Instances into the larger Reserved Instance, all the smaller instances must have the same expiration time.

  • EC2 Reserved Instance payment option:
    • All Upfront: One has to pay for the entire Reserved Instance term with one upfront payment. This option provides you with the largest discount compared to On-Demand instance pricing (max 75% for 3 years terms).
    • Partial Upfront: One has to make a low upfront payment and are then charged a discounted hourly rate for the instance for the duration of the Reserved Instance term. This option provides up to 60% (for 3 years terms) discount.
    • No Upfront: It does not require any upfront payment and provides a discounted hourly rate for the duration of the term. This option provides up to 33% discount.
    • Amazon EC2 savings with Reserved Instances

The following table shows an example of the savings for EC2 Reserved Instances for a Standard and Convertible, for 1- and 3-year term running a single t2. large Linux instance, in the US East (Ohio) region.

Standard 1-year term

Payment OptionUpfrontMonthlyEffective HourlyOn-Demand HourlySaving over On Demand
No Upfront$0.00$41.98$0.058$.092838%
Partial Upfront$240.00$20.00$0.05541%
All Upfront$470.00$0.00$0.05442%

Convertible 1-year term

Payment OptionUpfrontMonthlyEffective HourlyOn-Demand HourlySaving over On Demand
No Upfront$0.00$48.25$0.066$.092829%
Partial Upfront$276.00$23.00$0.06332%
All Upfront$541.00$0.00$0.06233%

Standard 3-year term

Payment OptionUpfrontMonthlyEffective HourlyOn-Demand HourlySaving over On Demand
No Upfront$0.00$29.27$0.04$.092857%
Partial Upfront$488.00$13.58$0.03760%
All Upfront$917.00$0.00$0.03562%

Convertible 3-year term

Payment OptionUpfrontMonthlyEffective HourlyOn-Demand HourlySaving over On Demand
No Upfront$0.00$33.65$0.046$.092850%
Partial Upfront$561.00$15.55$0.04354%
All Upfront$1099.00$0.00$0.04255%

 

Amazon RDS Reserved Instance

Amazon RDS Reserved Instances allow us to reserve a DB instance for a one or three year term and in turn, receive a significant discount compared to the On-Demand Instance pricing for the DB instance. Like EC2 instances, it can be purchased using No Upfront, Partial Upfront, or All Upfront options.

Amazon ElastiCache Reserved Nodes

Here we have to make a one-time payment for the node we want to reserve (Either for 1 or 3-year terms). After the reservation, we receive a significant discount on the hourly charge for that node.

Amazon Redshift Reserved Nodes

Like the Amazon Elasticache, the Amazon Redshift Reserved Node provides us the significant savings over on-demand pricing, but we have to make a one-time payment to reserve the node (Either for 1 or 3-year terms).

Amazon DynamoDB Reserved Instance

Here we have to pay a one-time upfront fee and commit to paying for a minimum usage level at specific hourly rates for the duration of the reserved capacity term. Any throughput we provision in excess of the reserved capacity is billed at standard rates for provisioned throughput.

Monitoring AWS Bill

Aws provide following monitoring tools to monitor AWS bills: Billing Dashboard

The AWS Billing Dashboard lets us view the status of the month-to-date AWS expenditure. It lists the services that account for the majority of your overall expenditure. It forecasts the month-end bill, but it is rarely accurate.AWS Billing Dashboard just gives an overview of the cost of AWS services and not detailed enough to be of use for serious monitoring.

Detailed Billing Report

The bills page gives us the most up-to-date information on AWS service costs and usage. It includes a monthly bill and a detailed breakdown of the AWS services we are using. We can further download the bill in PDF and CSV format for analysis.

Cost Explorer

Cost Explorer is a tool that enables us to view and analyze the AWS costs and usage. We can explore the AWS usage and costs using the main graph, the Cost Explorer cost, and usage reports, or the Cost Explorer RI report. We can view data of the last 13 months. Mostly, it accurately forecasts the month-end bill and next month bill. The AWS has a lot of potentials which you can extract and use for optimization of your business. With the help of information on AWS above you can map your way through AWS and get the best out of it.

Request a quote