ACO Architecture: 5 Tips to Auto-CostOptimization on AWS

Part -1: ACO Architecture

Naoufal EL GAFA
CodeX

--

AACO — Cost Optimization on AWS

I remember my first bill with AWS was $5 in 2016 knowing I had a year of the free tier 😠, I was shocked because I was sure that I only used the included services in the free offer.

However, when I studied my billing I discovered that I chose developers Support and is not included in the free tier 😛.

Conclusion : Ignorance is Expensive 😲

Budgeting on AWS is such an important aspect that an architect must take care of. we can always suggest a good-looking architecture with micro-services tied to serverless with managed services etc … 💪

But if the bills are too high at the end of the month we will have a problem 😅

The AWS Well-Architected is based on five pillars: operational excellence, security, reliability, performance efficiency, and cost optimization.

We'll talk in this story about the fifth.

Cost Optimization

The cost optimization pillar focuses on avoiding unnecessary costs. Key topics include understanding and controlling where money is being spent, selecting the most appropriate and right number of resource types, analyzing spend over time, and scaling to meet business needs without overspending.

AWS has made a whitepaper that groups best practices for cost optimization to help companies, but I’ll make it simple as usual and I’ll show you some tips to implement the ACO Architecture (Auto Cost Optimization) for Cost Optimization in your different services by using AWS Budgets, SNS and Lambda.

This tips will work fine if you have an Individual AWS account.

If you belong to an AWS organization or you are a company, they are other advanced tools to FinOps

5 Tips to Implement ACO Architecture :

The ACO Architecture is based on a simple reflex:

If my spent budget reaches X% of my threshold I’ll stop, pause or whatever the appropriate(s) service (s) 👌.

You have two choices to do it :

  • Cost Budget: Based on a specific amount. (For example 20$)
  • Usage Budget: Based on service usage. (For example Ec2 Data Transfer, ECS Fargat vCPU Hours)

In this Story, I’ll focus on Usage Budget

I - Abstract Architecture :

Abstract ACO Architecture

To summarize this architecture :

I create a budget in whish I define a threshold for my Usage Service to send an Alert to a Specific SNS Topic that will trigger a Lambda to — stop, pause, or whatever you want — specified services.

II - 5 Tips To implement :

  1. Refer to your M-1 (previous month…) billing to see what service you need to optimize cost.
  2. Extract Usage Type Category, Usage Type, And Usage from the concerned service as shown on the billing image bellow (Bills of the M-1). “We will use it at the next story”
  3. Create a Budget and Define a Threshold-based on your Usage Type & Usage Per Month
  4. Send Budget Alert to an SNS Topic that triggers a Lambda to Stop/Pause your specific service if the spent budget reaches an X% of the defined threshold
  5. Assign the appropriate Policies & Permission to Lambda & SNS Topic
AWS ACO Architecture — Bills
Bills of the M-1

Conclusion

As you can see a basic implementation of auto-cost optimization isn’t complex. You can apply this architecture in your personal project to avoid spending a lot of money.

In the next Stroy, I will Implement this Abstract ACO Architecture with the AWS Service “ECS Fargate Container”, by making a Terraform File that you can simply adapt and use for your own needs.

For those who don't know yet how to automate an AWS Architecture with Terraform and DevOps you can refer to my previous story here:

Thank you for reading my stories 🙏

If you Like it Share it 😜 and If you have any remarks, or if something doesn’t seem clear, please leave a comment or contact me on my Fb Page, Twitter, or via my website

--

--

Naoufal EL GAFA
CodeX
Writer for

Software Lead Architect Enjoy designing, creating, coding, and Cloud Deploy. https://elgafa.com