DEV Community

Cover image for How I host my Full-stack Application SaaS for Free on AWS
Remi W.
Remi W.

Posted on • Originally published at creativedesignsguru.com

How I host my Full-stack Application SaaS for Free on AWS

Deploying your application to production can become quite expensive on AWS if you don't take the time to think about your infrastructure. In this article, I will show you how I manage to host my full-stack application for free on AWS: Frontend, Backend, Database, Monitoring and Email service, all hosted for free on AWS.

Context

I'm an indie maker with limited financial resources, I need to optimize the hosting costs. If you are working for a larger company, this article can still give you some idea on how to reduce your cost on AWS.

My whole application is hosted on AWS. Because everything is centralized on AWS, it makes easier to manage the infrastructure. Also, as a solo developer with limited time, the infrastructure is 100% serverless. So, you don't need to worry about server management, AWS handles it for you. They configure and update the server for you. Thanks to the centralization and serverless, I can focus on my business and product.

You can check out the live demo of my application at the full-stack React Boilerplate demo. Or, if you need to see a real SaaS product, you can check out PostMage app.

Authentication

Let's start by looking at the authentication where I use AWS Cognito to secure my full-stack application. All the authentication system is managed and secured by AWS, so I don't need to worry about it. With Cognito, it's extremely easy to implement email and social authentication with Google, Facebook, Amazon and Apple.

The good news is that AWS Cognito has a very generous free tier policy. Below 50,000 monthly active users, you can stay at the free tier without any time limitation (always free). I think it's one of the most generous free-tier policies in the market. For example, Auth0 only offers 7,000 monthly active users.

AWS Cognito email auth

Frontend

The developer experience has recently improved with Netlify and Vercel. With these two tools, I can build and deploy your frontend directly from your GitHub repository. Did you know you can have the same experience with AWS without any external services? Yes, with AWS Amplify Hosting, you can host your frontend on AWS without compromising on your developer experience.

AWS Amplify Hosting also offers a free tier, but it's limited to one year. The free plan includes 1,000 build minutes and 15 GB of bandwidth per month. Compared to Vercel and Netlify, you don't need to pay a subscription for each developer seat. With Amplify Hosting, you only need to pay based on your usage.

AWS Amplify Hosting logo

Backend

For the REST API, I host it on AWS Lambda, the serverless computer service from AWS. No need to set up an EC2 instance to host a backend. So, no need to update your server and no need to manage the scaling. With AWS Lambda, you only need to deploy your code and AWS will take care of the rest.

You can invoke your AWS Lambda 1 million requests per month for free. And, it isn't limited in time. When you go above the free tier, you only need to pay based on the number of requests. Basically, you don't need to pay anything if you don't have any requests.

AWS Lambda

In the past, you usually need an API gateway. It's needed to route requests to the correct Lambda function. It also comes at a small cost. But, again, there is also a free tier ;) Like AWS Lambda, the API gateway can handle 1 million requests per month for free. More recently, AWS has released AWS Lambda Function URLs. So, you can directly invoke your Lambda function without an API gateway. And, the good news with AWS Lambda Function URLs is free with Lambda.

Database

You might already notice that there aren't a lot of providers for serverless databases. Fortunately for us, DynamoDB checks all the requirements you expected for a serverless database: scale to zero, pay per request, automatically manage the scaling, and so on. So, I choose DynamoDB as my database for my SaaS application.

Again I won't disappoint you ;) DynamoDB has a very generous always free tier policy: 25 GB of storage, 25 provisioned Write and Read Capacity. Based on the official description, this enough to handle 200 million requests per month. I don't know this is true or not, but I think it's definitely enough to handle a middle-sized application for free.

AWS DynamoDB serverless database

Monitoring, Logging and Observability

The infrastructure is 100% serverless and managed by AWS. But, I still need to keep an eye on the application to see if there are any errors. So, I use CloudWatch to monitor the application and the infrastructure. I also set up some alerts to be notified when something goes wrong.

For CloudWatch, AWS offers an always-free tier: 10 custom metrics, 10 alarms, 5GB of log ingestion, etc. Using only what the free tier offering, you can still have a better idea of how your application is behaving in production.

AWS Cloudwatch monitoring

Email

By using AWS Cognito for the authentication, there are several steps in the authentication process where Cognito will send an email with AWS SES. For example, if you have a registration form, you can send a confirmation email to the user after he registers.

Not only for the authentication, but the application itself also needs to send an email. My SaaS application has team support where users can invite their friends or coworker to work together in the same workspace. So, the application needs to send an email when the user start inviting his friends.

You won't get any surprise ;) But, AWS SES has an extremely generous always-free tier: you can send 62,000 emails per month for free. I think it's one of the most generous free tiers in the market for email service.

AWS Email service SES

Conclusion

All the AWS services I used for my SaaS application have a free tier. Currently, I'm paying nothing for hosting my full-stack application on AWS. In this article, I hope I give you some inspiration on how you can also reduce your AWS bill.

If you like my article and my stack, you should be definitively interested in my Full-stack React Boilerplate, a pre-configured template for you to start a new project quickly. It's exactly the same stack mentioned in the article: 100% serverless hosted on AWS.

React SaaS Template Starter

You'll find inside the boilerplate everything configures for you. It includes TypeScript, Tailwind CSS, Serverless framework, Linter, Code formatter, Jest, Cypress and VSCode configuration. So, you don't need to lose your time fighting with configuration files.

Not only you'll find configuration files in the boilerplate, but you'll also find code for your application. For example, it includes pre-built code for authentication, landing page, user dashboard, multi-tenancy support (team support), subscription payment, and more. Instead of wasting time reinventing the wheel and developing from scratch, you can focus on the core of your project. It'll save you months of development time.

Top comments (0)