How to Save Money When Hosting on AWS

Published | 5 min read

When I started my first startup GrowRecruit I went with the recommended setup. However, I soon found that what is recommended is actually quite costly for a bootstrapped startup.

If your product is still at the MVP stage (Minimum Viable Product) and you haven’t got customers yet, you want to avoid spending large amounts on AWS hosting.

My initial setup consisted of the following:

  • VPC with Public and Private Subnet and NAT Gateway
  • 2 t2.small instances RDS database cluster (one read, one write),
  • 2 t2.micro instances, one for WordPress the other for my API
  • 2 S3 buckets
  • Route 53

This is a fairly small setup for bootstrapped SaaS, I would have liked to go with a smaller RDS instance, however, t2.small was the smallest available that offered encryption.

The total cost per month $146.95! Not exactly the cheap bootstrap price I was looking for.

Step 1: Cut unused services

To start working out what you need to cut, you need to look at your bill. This is what mine looked like:

AWS Charges

As you can see the expenditure is mostly in 3 areas: Elastic Compute Cloud, Relational Database Service and VAT.

Elastic Compute Cloud

I have 2 EC2 Instances both t2.micro, one for my API the other for a WordPress installation which I use for my marketing site.

With one of these instances covered under Amazon’s Free Tier, the cost for running these instances is $3.65. This would have been $9.23 but I opted for a reserved instance. I will cover what reserved instances are below.

So where on earth was this other $49.42 coming from?

  • NAT Gateway - $35.72
  • Elastic Load Balancer - $13.68
  • EBS - $0.02

So I was spending $35.72 on a NAT Gateway. So what is a NAT Gateway and do you need it?

NAT Gateway

The purpose of a NAT Gateway is to allow instances in your private subnet to access the internet but prevent the internet from accessing those instances.

In my case, the only thing in my Private Subnet was my database and that didn’t need internet access. So I got rid of my NAT Gateway and managed to save myself $35 a month.

If you do need a NAT Gateway you can set up a NAT Instance which may work out cheaper for you.

Elastic Load Balancer

The second highest expense was the Elastic Load Balancer (ELB). Now I am running my API using Elastic Beanstalk and the ELB is required for SSL on my API endpoint. So there was no getting rid of that one.

Step 2: Commit to payment or pick your instance type

AWS has 2 ways you can save money, reserved instances and spot instances.

Reserved Instances

Reserved instances are a great way to save money if you are planning on keeping your servers long term.

Amazon has 3 different ways that you can reserve an instance.

  • All Upfront - This obviously has the highest upfront cost but you save the most in the long run.
  • Partial Upfront - In this case, you pay a portion upfront and then pay a discounted hourly rate for the rest of the term.
  • No Upfront - As the name suggests you don’t pay anything upfront but you do commit yourself to a fixed monthly outgoing each month for the duration of the term.

In the case of my EC2 instance, I went with the Partial Upfront payment which cost me $43 upfront which brought my monthly cost down to the $3.65 you see above.

I did the same with my RDS instances but this time I chose the No Upfront which brought my database costs down from $68.30 to around $53. However, I wouldn’t recommend this option as it ties you into a contract for at least a year.

Spot Instances

The other option you have here to bring your cost down is spot instances. With spot instances, you can save significant amounts on your EC2 instances but it comes at the cost of reliability.

With Spot Instances, you are getting spare computing power which would otherwise go to waste. When you set up a spot instance you can specify the maximum amount you are willing to spend and the type of instances you want to have.

Spot instances are a great option for fault tolerant background processes that can afford not to run occasionally.

They are also a great option for test environments, although just make sure QA know to take this into account when they are testing your software.

Step 3: Move to cheaper options

If you have run out of options with your current configuration it may be worth considering AWS’s cheaper configurations.

S3 Storage

Amazon S3 storage is dirt cheap. I am currently running 3 blogs (including this one) and the frontend of GrowRecruit for $0.05 a month.

To save even more money I created a static copy of my Wordpress blog running on my EC2 instance using the WP Static Site Generator Plugin and hosted it in an S3 bucket with CloudFront on top.

The Wordpress theme I was using was overly bloated and took an age to load. I switched this out for a super fast Gatsby blog, like this one.

Go Serverless

You can save a lot of money by going serverless if your application isn’t being used heavily. Amazon offers a range of serverless technologies including Aurora Serverless and Lambda Functions.

If I was going to rewrite my startup I would definitely consider using serverless technologies. Just make sure you keep an eye on the costs. If you start getting a lot of traffic you might want to consider going the instance route.

Conclusion

With the above tweaks, I managed to nearly half my AWS costs and now pay around $75 a month.

If I was using Aurora Serverless however it would be a small fraction of that.

Unfortunately, Aurora Serverless wasn’t out yet when I set up GrowRecruit and I am now tied into a year-long contract! Lesson learned the hard way on that one.


Was this post useful?
If you found this post useful and would like to support me, you can do so by buying me a coffee. Donations help keep this blog ad free.

ALSO ON ALEXHYETT.COM

Taking a Creative Sabbatical as a Software Engineer

Taking a Creative Sabbatical as a Software Engineer

  • 28 September 2022
The last couple of years have been tough for many people. A mix of lockdowns and general anxiety has left many feeling burnt out and exhausted. For software developers, the move to working 100% remotely wasn’t as much of an upheaval as it has been fo...
Adding Inline Javascript to a React App

Adding Inline Javascript to a React App

  • 11 February 2022
Let me start this with a disclaimer, I am not a React expert and I am sure there are probably other ways to do this. If you know of a better way then please let me know in the comments! I have recently added Giscus to my blog which is a great way to ...
Privacy Focused Blog Services

Privacy Focused Blog Services

  • 28 January 2022
Towards the end of 2021, I started getting into web3 a lot more. Not only did I join the Developer DAO but I also launched my own NFT collection and wrote a few blog posts on the topic. One of the key components of web3 is the ownership of data. In w...
What is DeFi? Understanding Decentralized Finance

What is DeFi? Understanding Decentralized Finance

  • 19 November 2021
If you are new to the crypto space the concepts of decentralised finance can seem a bit overwhelming. There are so many new terms to try and understand, it can be challenging to see how everything fits together. I have been working in the traditional...
Using Hashnode as a Source for Gatsby

Using Hashnode as a Source for Gatsby

  • 05 November 2021
I have done quite a few website migrations over the years. My blog like many first started out on WordPress. After several attempts at optimisation, I ended up generating a static version of my WordPress website. On my static site generation journey...
What is Web3? The Decentralised Internet Explained

What is Web3? The Decentralised Internet Explained

  • 15 October 2021
If you have stumbled upon this article you have probably seen the term web3 being mentioned around the internet. Especially on Twitter at the moment it seems to be the latest buzzword. With all the hype around NFTs and crypto at the moment, a lot of ...
Ditch the Ads: The Future of Website Monetization

Ditch the Ads: The Future of Website Monetization

  • 08 October 2021
Do you remember that scene in Ready Player One, when IOI are showing what the future of the Oasis will look like once they take over? “We have determined that we’ll be able to fill 80% of the user’s display with advertising before inducing seizures”...
Dealing with Imposter Syndrome as a Software Developer

Dealing with Imposter Syndrome as a Software Developer

  • 28 May 2021
I have been a professional software developer for over a decade and I have been writing code for over 25 years. However, sometimes I still feel like a fraud. It turns out, I am not the only one that feels this way and they have a name for it, it is c...