Ten Steps To Reduce Your AWS Bill

by | Mar 7, 2024

If you’re in charge of a development team at a start-up, you can scale your capacity as your business expands by leveraging AWS to offer your infrastructure. Up until the CFO swings over and inquires about the AWS bill, everything is going according to plan. You believe the CFO is overreacting, so in an effort to appease them, you review the bill and find that it went from “fair” to “tragic” really rapidly. How did that come about? And how can you make it right before others start to see you as a useful cost-saving measure?

Just to make sure it doesn’t happen again, it’s important to first consider how this entire problem came about. Giving developers the freedom to construct cloud computing resources as they see fit is a reasonable approach, but they must exercise caution to avoid generating resources that never get shut down and continue to cost you money. At least you didn’t take any developers seriously when they said that CPU and memory were inexpensive.

What will you do about the bill then? You might find the following actions useful:

Tag everything :

In AWS, you may “tag” practically any resource type, including servers, lambdas, databases, and load balancers. Tag everything to be able to see how much each resource and resource category is costing you.

So that you can calculate the expenses by resource type, department, environment, and other factors, you’ll need some kind of schema or pattern. It will become clearer as a result exactly what is costing you money. You might wish to base your tagging on the straightforward schema listed below. We’re going to use our company name called SvaanTech.


Tag Name

Purpose

SvaanTech:Department

The department of the company that is responsible for the resource. For example it could be “Development”, “Sales”, “Accounting”, etc.

SvaanTech:Environment

The development environment where the resource belongs. This might be something like “Development”, “Test”, “Staging” or “Production”.

SvaanTech:Finance

A readable name for the resource.

SvaanTech:Owner

The name or email of the person responsible for the resource. For example a development machine will probably have a developer’s details in this tag. An accounting machine might have the CFO’s details.

SvaanTech:System

The system to which the resource belongs. For example “Build”, “CRM”, “Accounting”, etc.

SvaanTech:Purpose

The specific purpose for the resource. “DB”, “Video Server”, “Application Server”.

You must begin applying tags to each resource after choosing the ones you want to use. Start adding the tags to your system if you’re currently creating and updating it with a tool like Terraform. Otherwise, you must start adding tags by hand if you are still manually creating and updating resources. Avoid the temptation to put off doing this, and if it has to be added to your product backlog, put it at the top because it may genuinely stop your business from losing money.

At this stage, it’s important to note that lambda functions may be written to instantly apply tags to freshly manually generated resources. If you manually developed your resources, put a task to incorporate them towards the top of your queue; otherwise, you’ll have to keep manually adding tags

Request advice from AWS.

Use the suggestions that AWS will provide you with when you add tags to manually built EC2 instances. The “AWS Compute Optimizer” tool is available on every EC2 instance; simply check the box to enable it, and AWS will begin to examine that instance. You’ll begin to receive recommendations based on the CPU and network activities for each instance after around two weeks.

Allocating resources using Elastic Beanstalk

It makes no sense to pay to run so many servers if there isn’t much activity in your system if you just need 10 to run it at maximum demand. AWS may create and stop additional machine instances by using Elastic Beanstalk when the CPU utilisation on the present machines reaches a predetermined threshold. As a result, you may maximise your processing capabilities while lowering your expenses.

The costs of your development and testing systems can be reduced if you set them up to operate in a similar manner. Make sure you don’t pay for your development or systems to operate round-the-clock as it’s quite improbable that they will.

Set billing alerts:

AWS enables you to set up billing alerts that send you emails whenever your bill increases by more than a specified amount in a day. Make one, set it to increase by a few percent (you may change it), and use it! You need to be aware of any continual increases in the number of instances or resource use by your development team.

Resize your database servers :

You have to do it manually because AWS database servers don’t have the same “AWS Compute Optimizer” settings as EC2 instances.

Starting out, you should use aliases to access all of your databases, such as mysalesdatabase.mycompany.com. Why? Because AWS assigns a new resource ID to each database server you recreate, Simply edit the target resource ID in the alias DNS record to use an alias. You must modify the settings for each machine that accesses that database if you are not using an alias. It doesn’t make sense to endure that degree of danger. Create aliases if you aren’t already doing so, then update your programme to allow access to them.

Additionally, you should turn on “Enhanced Monitoring” for your database instances; for the time being, go with the default settings. This gives you significantly greater visibility into the database’s functionality. Check to determine whether you genuinely need more than the minimum if someone has increased the “Provisioned IOPS” settings from the default. Set an alarm to go off when the IOPS level reaches 1000 if you’re unsure. You can lower the limit if it never fires.

After making these changes, you may begin monitoring the database servers in your system. As a general rule, you should be able to downgrade to the next RDS instance size if your database CPU seldom goes above 50% and there are no query queues even during peak times. Additionally, production servers frequently don’t need to be as large as they are, and development and test servers should be far smaller than production servers. Even while large servers ARE necessary, the situation doesn’t always remain that way. The load on the database server might be significantly impacted by a software update or by restructuring a very inefficient piece of business software.

I’ve seen DB servers reduce their CPU utilisation from 80% to 15% after being completely redesigned and configured. Try reconfiguring the server to be one or even two sizes smaller if it occurs to you. You may halve your server bill by doing it one step at a time.

Make sure your allotted storage is a suitable size when you are adjusting the database server settings. Even if you just use a few hundred gigabytes, you’re paying too much if Terabytes of space are allocated.

Instances should be replaced by Lambdas and APIs:

Many Lambda functions can take the role of numerous services that are hosted by one or more instances. You receive the following when you utilise the AWS API Gateway:

  • Various API types, including inexpensive HTTP APIs
  • The API Gateway uses IAM, JWT, and AWS Cognito User Pools to offer security.
  • Auto-scaling to manage any demand level up to a certain limit.

You may save the hassle and expense of managing different EC2 instances and associated infrastructure by using API Gateways. Additionally, they alter the quantity of resources on hand to precisely meet demand. The API Gateway enables you to make a service that may be encapsulated in a Lambda externally accessible with all of the security and authorization that is needed.

Purchase resources ahead of time :

Purchase resources on-demand When you first start out, AWS resources are fantastic, but the cost adds up quickly. You should acquire capacity in advance once you have a manufacturing system, without a doubt. Keep in mind that pre-purchased EC2 instances may typically be upgraded to different kinds, however you should consult AWS before making too many changes. While prepaid RDS servers, on the other hand, frequently cannot be changed, you might choose to use the original RDS instance type for testing or development if you need to modify the RDS instance type midway during the prepay time.

Automate as much of your monitoring as possible :

JanitorMonkey is a programme that Netflix made some years ago. Its task is to scan through your AWS system and identify underutilised resources. Once it has located them, it will notify you of them and gives the option to turn them off. Similar work is also performed by Cloud Custodian.

Many of your cost-saving tasks may be automated using one of these applications or others similar to them. I’ve previously worked for organisations that had servers and other resources that were not in use included in automated weekly emails, along with information about who owned them and how much they cost. Nothing convinces individuals to turn off useless technology like a weekly reminder with numbers attached.

Automate the deployment and allocation of your systems :

If you manually assign resources, each change you make requires manually updating every resource that depends on the altered resource.

Instead, you may describe dependencies, tags, accounts, and other things if you create the system in Terraform, or perhaps in Docker and CloudFormation. Any changes you make to one resource just affect that one, and any other aspects, such as tags or other components, remain unchanged and don’t require updating. This reduces deployment complexity and development time by ensuring that just the changes you make are updated.

Repetition of the aforementioned actions every week :

It’s simple to put in a lot of effort to lower your AWS charge, obtain an acceptable outcome, and then go on to the following undertaking. The issue with this is that your team is likely making modifications to the environment on a regular basis, which means that your adjustments will eventually be overwritten. Setting aside some time each week, ideally at the same time, to go through all of the aforementioned processes again is the greatest method to prevent this from happening. You’ll develop the habit of periodically reviewing the systems and come to know them better. Ideally, you should include the development team so they can see the impact of your modifications and to highlight the necessity.