As businesses grow, managing and optimizing cloud infrastructure becomes a crucial task, especially when costs start escalating. At one point, one of our client’s AWS bill reached $5,000 per month, and we knew we needed to take action. Through careful planning and smart decision-making, we managed to bring the AWS costs down to $1,200 per month without sacrificing performance or scalability.
In this blog, we’ll share the specific steps we took to optimize the infrastructure and reduce costs by over 60%. Before that let’s have a brief idea of the problem and the solution.
Problem:
The client encountered significant challenges with high AWS costs due to inefficient infrastructure management. The existing setup, which utilized separate instances for each dashboard or admin application, resulted in unnecessarily inflated monthly bills. This inadequate scaling of services, led to further complications and negatively impacted the client’s financial health and overall growth.
Solution:
To address these issues, we implemented an infrastructure optimization strategy. Our first step was to shut down unused services and eliminate wasteful resource consumption. Additionally, we cleaned up the existing databases by identifying and removing data associated with obsolete projects, effectively decluttering the system and reducing operational costs.
This approach helped the client regain control over their infrastructure, cut costs, and optimize performance, creating a more scalable and cost-efficient system.
Next, let’s explore the key steps we implemented and highlight important considerations to keep in mind.
1. Disabling Unnecessary Services
Over time, certain services that were initially important became outdated or unnecessary. However, these services were still running and consuming resources, contributing to high AWS bill.
Solution: We performed a full audit of all running services and identified which ones were no longer necessary. By shutting down these services, we eliminated unnecessary compute and storage costs, significantly reducing the monthly expenditure.
2. Upgrading MySQL RDS Version
Client’s MySQL RDS instance was running on an older version, which was not only inefficient in terms of performance but also more expensive.
Hence, We upgraded the MySQL RDS instance to the latest version (MySQL 8). The new version offered better performance and security while being more cost-efficient. This move helped us improve our database performance and reduce overall RDS costs.
3. Halting Inactive Cron Jobs
The client had several cron jobs running periodically, but some of these jobs were no longer necessary or relevant to their current applications. These jobs were consuming resources, even though they weren’t adding value.
Solution: We reviewed all the scheduled cron jobs and identified the ones that were redundant or no longer required. By halting these inactive cron jobs, we saved on compute costs and reduced waste.
4. Bundling Features Under One Application
Previously, features were spread across different applications, each running its own separate instances and backend services. This led to duplicated infrastructure costs, as each application required its own set of resources.
Solution: We bundled these features under a single application. By combining related features into one larger application, we streamlined our resource usage, reduced the need for separate instances, and minimized the overall infrastructure costs. This consolidation allowed us to scale resources more efficiently and take advantage of cost savings through shared resources.
5. Right-Sizing Instances
AWS offers various types of EC2 (Elastic Compute Cloud) instances for different workloads. Often, users overestimate their computing needs and run instances that are larger than necessary. Here’s how you can right-size your EC2 and RDS (Relational Database Service) instances:
- Monitor Utilization: Use AWS CloudWatch to monitor CPU, memory, and disk usage across your instances. Identify underutilized instances.
- Downsize Instances: Once you’ve identified over-provisioned instances, switch to a smaller instance type. For example, if a t3.large instance is only using 10% of its CPU, consider moving to a t3.medium.
6. Leverage Reserved Instances and Savings Plans
AWS offers discounts if you commit to long-term usage. For workloads that are predictable and run continuously, you can save significantly by using:
- Reserved Instances (RIs): By committing to use specific instance types over a 1 or 3-year period, you can save up to 75% compared to On-Demand pricing.
- Savings Plans: If you need more flexibility, AWS Savings Plans offer similar discounts to RIs, but with the ability to switch between instance types, regions, and even services like Lambda.
7. Optimize Storage Costs
Storage is often a hidden cost that can add up quickly. Optimizing your storage can lead to substantial savings.
- S3 Lifecycle Policies: Move infrequently accessed data to lower-cost storage classes like S3 Infrequent Access (IA) or S3 Glacier. S3 Lifecycle Policies allow you to automate the transition of objects based on usage patterns.
- EBS Volume Optimization: Review and right-size your EBS (Elastic Block Store) volumes. Delete unused EBS volumes and take advantage of lower-cost volume types for less critical data.
- Snapshots: Regularly delete old or unnecessary EBS snapshots to reduce storage costs.
8. Enable Auto-Scaling and Load Balancing
Auto-scaling dynamically adjusts your infrastructure based on the current demand, ensuring that you only use (and pay for) the necessary resources.
- Auto-Scaling Groups: Set up Auto-Scaling Groups for your EC2 instances, so that during periods of low traffic, instances are automatically terminated.
- Elastic Load Balancing (ELB): Distribute traffic efficiently across instances and ensure you aren’t over-provisioning resources for peak times.
9. Optimize Database Usage
AWS offers several database options, and optimizing your database usage can result in substantial savings.
- Use Aurora Serverless: For variable database workloads, Amazon Aurora Serverless automatically adjusts capacity based on demand, so you only pay for what you use.
- RDS Reserved Instances: For predictable database usage, purchase Reserved Instances for RDS, which can offer significant savings over the On-Demand model.
Final Thoughts: Continuous Optimization is Key
Reducing AWS costs requires an ongoing commitment to analyzing and optimizing your infrastructure. By consolidating resources, stopping unnecessary services, upgrading outdated components, and moving to more efficient architectures, we were able to reduce our monthly AWS bill from $5k to $1.2k. Additionally, technology re-architecture plays a crucial role in optimization.
Here are the key takeaways from our optimization journey:
- Audit your infrastructure regularly to identify unused or unnecessary services.
- Consolidate services and features where possible to reduce duplication and resource fragmentation.
- Upgrade services and use the latest versions for better performance and cost savings.
- Use centralized and scalable backend services to reduce complexity and optimize resource usage.
By following these strategies, you too can achieve significant cost savings while maintaining or even improving the performance of your infrastructure. Be sure to check out our other blogs at blog.ceegees.in.
Lead Engineer at Ceegees Software Solutions Pvt Ltd