AWS Cloud Cost Optimization Tips!!!

Cloud cost optimization is the process of reducing your overall cloud spend by identifying mismanaged resources, eliminating waste, reserving capacity for higher discounts, and Right Sizing computing services to scale and increase Elasticity of resources. cloud customers are charged for the resources they order, whether they use them or not and there is always high chance that good percentage of cloud costs are wasted if we don't follow best practices.

In this blog, I will share some useful cloud cost savings tips which can help us to achieve good amount of savings.



Source : https://serverguy.com/


Cost Optimization Pillars:


Regardless of your workload or architecture, there are five cost optimization pillars that apply across nearly all environments. Pillars of cost optimization are:


  • Right Size: Ensure that, what you provision, what you need. For example,for compute, you provision for CPU,memory,storage and network throughput.

  • Increase Elasticity: Traditional IT costs and hardware requirements are tailored for peak usage and are rarely turned off in off peak hours. We can optimize cost to meet dynamic needs and turn resources off when they are not needed.For example, we can turn off non production servers during weekends.

  • Leverage Right Pricing Model:AWS provides a range of pricing models( On demand and Spot instances for variable workloads and Reserved Instances for predictable workloads).Choose the right pricing model to optimize costs based on the nature of your workload.

  • Optimize Storage: AWS provides multiple storage tiers at prices designed to meet performance. By identifying the most appropriate destinations for specific for specific types of data, you can reduce Amazon Elastic Block Store (Amazon EBS) and Amazon Simple Storage Service (Amazon S3) while maintaining the required performance and availability. For example, where performance requirements are lower,using Amazon EBS Throughput Optimized HDD(st1) storage typically costs half as much as the default general purpose (GP2) storage option.

  • Continuous Monitor & Improve: To ensure that you extract full economic potential of the AWS cloud at any scale, we should :

  1. Define and Enforce Cost Allocation tagging

  2. Define metrics, set target and review.

  3. Enable teams to architect for cost via training,visualization of progress goals and a balance of incentives.

  4. Assign optimization responsibility to an individual or to a team.


Cost Optimization : AWS Compute Optimizer for Right Sizing purpose.


AWS Compute Optimizer recommends optimal AWS Compute resources for your workloads to reduce costs and improve performance by using machine learning to analyze historical utilization metrics. Over-provisioning compute can lead to unnecessary infrastructure cost and under-provisioning compute can lead to poor application performance. Compute Optimizer helps you choose the optimal Amazon EC2 instance types, including those that are part of an Amazon EC2 Auto Scaling group, based on your utilization data.

By applying the knowledge drawn from Amazon’s own experience running diverse workloads in the cloud, Compute Optimizer identifies workload patterns and recommends optimal compute resources. Compute Optimizer analyzes the configuration and resource utilization of your workload to identify dozens of defining characteristics, for example, if a workload is CPU-intensive, or if it exhibits a daily pattern or if a workload accesses local storage frequently. The service processes these characteristics and identifies the hardware resource headroom required by the workload. Compute Optimizer infers how the workload would have performed on various hardware platforms (e.g. Amazon EC2 instances types) and offers recommendations.


Cost Optimization : Increase Elasticity .


Optimize cost to meet dynamic needs and turn resources off when they are not needed.


Some of the quick win approaches are :


  • Through Auto scaling , setup scheduler to terminate EC2 in non business hours and bring back online in business hours.

  • Setup Automated pipeline , stop EC2 in non business hours and bring it back during business hours again. This approach will be useful when we want to stop the instance rather than terminating to avoid any data loss.

  • Using Cloud-watch, collect and track metrics , monitor log files and automatically react to changes in AWS resources.

  • Terminate unused infrastructure such as load balancer etc.

Cost Optimization : Leverage Right Pricing Model.


Choose the right pricing model to optimize costs based on the nature of your workload.


Key Considerations:

  • Reserved Instance provide user significant discount( up to 75%) compared to on-demand pricing.

  • AWS is now providing Instance size flexibility with EC2 and RDS. In past,Reserved Instance purchase was tied to a particular instance size.If you wanted to change sizes, you were out of luck.But AWS now allows Instance size flexibility which allows you to apply a Reserved Instance configured for one instance size to another instance of a different size as long as you stay in the same instance family. So it is another way to match your supply to your demand but also to add cost savings and further optimization.

  • Spot Instances are available at up to 90% discount compared to On-demand prices.

  • For On demand instances, selecting the latest generation/cost effective instance types can save significant money for users.

For example:

  1. Using AMD or ARM based instance for development /test purpose can save more (Savings potential is up-to 40%)

  2. Use of EC2 T3 General Purpose in place of T2 instances can save good cost.

Cost Optimization : Optimize Storage.


Suggested Approaches:

  • S3 Intelligent tier/configure life cycle policy.

  • Setup rules for S3 buckets for automatically move data objects to cheaper S3 storage tiers as object are accessed less frequently or to automatically delete objects after an expiration date.

  • Use general purpose SSD (gp2) volume for development and test environment for cost efficiency.

  • Monitor volumes periodically to identify ones that are unattached or appear to be underutilized or over utilized.

  • Delete unattached Amazon EBS volumes.

  • Resize or change the EBS volume type.Use the elastic volumes feature to change the size of the volume type.Optimize the capacity so that you are paying only for what you use.

  • Delete stale Amazon EBS snapshots.

Use of EFS as storage:


Amazon Elastic File System (EFS) provide simple, scalable file storage for use with EC2 instances.Amazon EFS supports any number of instances at the same time.


Advantage of EFS:

  • EFS allocate storage based on your usage and user needs to pay for what they use.Butt for EBS volumes, user is charged for allocated storage whether user use it or not.

  • Same EFS can be mounted with multiple EC2.

  • Amazon EFS infrequent access (IA) is a storage class that provides price/performance that is cost optimized for files not accessed everyday with storage price up-to 92% lower compared to Amazon EFS standard. To get started with EFS IA, simply enable EFS life cycle Management for your file system by selecting a life-cycle policy that matches your need.

Cost Optimization : Optimize Serverless Applications.


AWS Lambda Cost Optimization:


Optimize Function frequency: There are various factors that affect the invocation frequency of Lambda function. This is based on the triggers.Closely monitor your triggers and see if you can reduce the number of invocations over the time.

Optimize Memory confutation: Tuning your execution time and memory size will save you lot on computing resources and cost.There are high chances of cost getting out of your control due to variety of reasons.Some of them are DDOS attack,excess memory allocation or a simple bug in your code bundle.

Writing Efficient Code:The function that executes in half the time is a function that cost you half the money.One must note that the execution duration is simply proportional to the amount ,user will be charged.

Monitoring Data Transfer: While talking about Lambda charges, often times it gets out of our sight that you'll also be charged for the data transfer at standard EC2 data transfer rates.Hence, keep an eye on the amount of data,you're transferring out to the internet and other regions of AWS.


Summary:


It’s a known fact that moving to Amazon Web Services (AWS) can provide huge benefits in terms of agility, responsiveness, simplified operations, and improved innovation. However, many pre-assume that migrating to the public cloud will lead to cost savings. In reality, AWS cost optimization is harder than you think, as organizations need to implement management, governance, and automation. Otherwise, you won’t even have the slightest idea until the bill actually hits you.


Hope this Article will give you some starting point on 'Cloud Cost Optimization'


Happy Reading :).


Thank you.

Recent Posts

See All

Steps to Setup kubernetes Cluster!!

In this blog, I will show you, how you can set up a Kubernetes Cluster using Kubeadm. For this hands on, I have used Ubuntu EC2s hosted in AWS environment.I have launched one master node and one work