Tech Blog

Cloud Computing

AWS Cost Optimization Techniques

By Keerthik Shenoy4 min read
← Back to blog

AWS is the world’s leading cloud computing platform, providing a wide range of services including computer computing, storage, networking, and platform as a service (PaaS).

AWS cost optimization requires identifying areas for cost-saving measures, tracking your usage, and putting advice into practice. Your Amazon costs are largely influenced by the cost of EC2 instances provided by the Elastic Compute Cloud (EC2).

We can reduce costs across our Amazon account by switching instances from on-demand pricing to lower-cost spot instances or reserved instances, or by applying savings plans. Many optimization strategies involve reducing the cost of EC2 instances.

We can save more costs by selecting the right purchase model while launching servers.

1. On-Demand Instances:

  • Pay for computing capacity by the second with no long-term commitments 
  • Spiky workloads to define needs 

2. Reserved Instances (Ris):

  • Make a 1 or 3-year commitment and receive a significant discount on On-Demand prices
  • Committed and steady-state usage 

3. Savings Plans:

  • Same great discounts as Amazon EC2 Rls with more flexibility 
  • Flexible access to compute 

4. Spot Instances:

  • Spare Amazon EC2 capacity at savings of up to 90% on On-Demand prices
  • Fault-tolerant, flexible, stateless workloads

Typically, most of us use serverless models for software development and automation. AWS Lambda is a renowned service for serverless models. For this reason, optimizing Lambda functions is also more important for cost savings.

Optimizing AWS Lambda Functions

Cost Factors:

  • Number of executions 
  • Duration and memory used (combined as GB-seconds )
  • Data transfer

Optimization Techniques:

  • Choose the correct memory allocation 
  • Validate function size using AWS Lambda Power Tuning

Storage optimization: Amazon S3 storage classes:

Another commonly used service in AWS is S3 for storing data. So, we can segregate data stored in S3 buckets into different classes based on access patterns to save some cost.

S3 provides some of the storage classes where we can store data based on how quickly and regularly, we want to access that data.

Amazon S3 Standard:

  • Active, frequently accessed data 
  • Milliseconds access 

Amazon S3 Intelligent Tiering:

  • Data with changing access patterns
  • Milliseconds access 

Amazon S3 Standard-IA:

  • Infrequently accessed 
  • Milliseconds access

Amazon S3 One Zone-IA:

  • Re-creatable, less accessed 
  • Milliseconds access

Amazon S3 Glacier:

  • Archive data 
  • Select minutes or hours 

Amazon S3 Glacier Deep Archive:

  • Archive data
  • Select 12 or 48 hours

General purpose SSD volume recommended for most workloads: gp3

EBS is the most common block storage we use while launching servers. By selecting the proper EBS volume type, we can also save some costs without compromising performance.

Some advantages of selecting gp3 over gp2.

  • Ideal for relational and non-relational databases, enterprise applications, containerized workloads, big data, file systems, media workflows
  • 3,000 baseline IOPS (versus 3 IOPS/GiB in gp2) and 1,000 MiB/s (versus 250 MiB/s in gp2); provision throughput and IOPS separately from capacity
  • Up to 20% lower storage price than previous gp2 volumes

AWS also provides many services for monitoring and reducing costs, so in this section, we will look at some important AWS services for cost optimization.

1. AWS Instance Scheduler:

  • AWS-provided solution
  • Custom start & stop schedules
  • Works with Amazon EC2 & Amazon RDS instances
  • Deploy using AWS CloudFormation
  • Selectively tag instances to schedule
  • Multiple schedules per instance
  • 5-minute granularity

2. AWS Compute Optimizer

  • Delivers recommendations for selected types of Amazon EC2 instances, Amazon EC2 AWS AutoScaling groups, Amazon EBS volumes, and AWS Lambda functions.
  • Lower costs and improve workload performance
  • Applies insights from millions of workloads to make recommendations 
  • Saves time comparing and selecting optimal resources for your workload

3.  AWS Trusted Advisor

  • Identify further cost savings recommendations by identifying
  • Underutilized Amazon EC2 Instances 
  • Underutilized Amazon EBS Volumes
  • Idle Amazon RDS Instances
  • Idle Elastic Load Balancing (ELB) 

4. AWS Pricing Calculator

  • Model your solutions
  • See the math behind the pricing
  • Find instances to match your needs
  • Model your solutions
  • See the math behind the pricing
  • Find instances to match your needs
  • Save and share estimates
  • Export to .CSV 

5. Forecasting with AWS Cost Explorer

Plan for future spending

  • Increased forecasting accuracy to plan with more confidence

Customize your forecasts

  • Use filters to forecast costs along specific usage dimensions 

Programmatic access

  • Forecasting also available via API 

6. AWS Budgets

       Customizable budgets: 

  • Set custom budgets for cost and usage thresholds 
  • Set utilization and coverage targets for your Reserved Instances and Savings Plans

       Ongoing monitoring and alerting

  • Receive regular budget reports 
  • Be alerted when cost and usage exceed (or are forecasted to exceed) the budgeted amount

       Flexible automation

  • Execute actions when a budget exceeds its threshold (actual or forecasted amounts) 

Keep reading

You may be interested in

Browse all articles →
How to Configure AWS CLI?
December 30, 20224 min read

How to Configure AWS CLI?

In Cloud platforms such as AWS, GCP, and Azure we have multiple ways to access cloud services and our resources like GUI (Console), CDK, and CLI. In today’s blog, we are going to look at CLI access in AWS. Like all other cloud providers, AWS also provides CLI access to their services for that first […]

By Keerthik ShenoyRead More →
AWS Automation with Python Boto3
December 30, 20223 min read

AWS Automation with Python Boto3

Automation plays a major role in In Cloud and DevOps, we have many tools to automate manual processes like Infrastructure automation with Terraform, for CICD Jenkins, GitLab, AWS, code pipeline, etc. In the same way, we can automate some of the AWS tasks with a simple python script using the oto3 library. Let’s see some […]

By Keerthik ShenoyRead More →
Terraform As a DevOps Tool (IaC) And Benefits (Part 2)
September 21, 20222 min read

Terraform As a DevOps Tool (IaC) And Benefits (Part 2)

In this article, we will explore terminologies and basic commands that can be used to interact with Terraform. Using Terraform init, an existing or new Terraform configuration can be initialized. As a beginner, you may get syntax errors or indentation errors. To validate theYAML data, use the Terraform “validate” command. The “Terraform apply“ command changes […]

By Utsav SolankiRead More →