5 Cost Saving Tips for AWS

Last updated on: 3/26/2024

Tip #1: Turn off your dev, staging environments when they are not in use

Many teams need to have development and staging environments to test their applications before they go live. These environments can be expensive to run 24/7 and can be turned off when they are not in use. You can use AWS Lambda functions to turn off your EC2 instances at a certain time of day and turn them back on when you need them.

Lambda functions can be written to switch off ECS containers, EC2 containers, RDS instances and many other resources. The more you switch off the more you save.

A good schedule could be to switch them off at the end of the work day, say 6pm and switch them back on at 8am and keep them off for the entire weekend. Another use case is to keep them off all the time for rarely used environments and switch them on via a AWS CLI call when needed.

Tip #2: Use Lambda functions instead of job workers

Lambda functions are very cheap and is a lot cheaper than having an EC2 or ECS container running 24/7 to perform basic tasks such as sending out emails or SMS messages.

For example, Laravel applications rely on a job queue system and if you send out your emails via the queue you will need a job worker to listen to the queue to process the jobs. Sending these jobs out to Lambda not only means you no longer need a job worker running 24/7 but it will automatically scale to large volumes of messages sent.

Tip #3: Use 1 NAT gateway for environments that dont need redundancy

NAT gateways cost money to run 24/7 and if you have multiple environments you may have multiple NAT gateways running. If you have a dev, staging and production environment you could have 6 NAT gateways running if you are following best practices and having 2 gateways for each environment. Use 1 gateway for environments that are not critical and don't need redundancy.

Tip #4: Containerize your batch job applications

If you have batch jobs that run on a schedule you can containerize them and run them on ECS Fargate. This will save you money as you only pay for the time the container is running. You can also use Lambda functions to run these batch jobs and save even more money.

A good example would be if you have analytics job that runs every night at 2am. You can containerize this job and run it on ECS Fargate and only pay for the time it runs instead of a EC2 instance running 24/7 with a cron job.

Tip #5: Check your usage and adjust the instance types

Check your usage of RDS, OpenSearch, EC2, ECS and other resource to make sure your instance type matches your usage. If you are not using a lot of CPU or memory then you can downgrade your instance type to a lower tier and save money.

AWS is also releasing new instance types that offer better performance to price ratios. Many of these new instance types are making use of ARM CPUs that they are rolling out. Check the latest instance types and see if there are alternatives to switch to.

Conclusion

The cloud makes lofty promises on cost savings when you move your infrastructure to them but like many things there are fishhooks you need to be aware of. Many organisations that did the "lift and shift" have found this out. To realise the cost savings you need to use the cloud providers native features such as Lambda functions and scheduling. Realising the cost saving requires a strategy and a plan to implement it.

Contact Us
Do you need help on your project or further insights? Let us know how we can help.