DEV Community

StuartCreed
StuartCreed

Posted on • Updated on

Hosting a Full Stack Web App

AWS

EC2

AWS EC2 costs about £7 a month (without storage is it £3 with mount storage). It is a IAAS (Infrastructure As A Service). You can do anything you want with it but you have to set it up yourself (which is simpler than you would think with Apache and NGINX). You can get this for 12 months free, then you have to pay £7 a month (roughly) afterwards.

Elastic Beanstalk

AWS Elastic Beanstalk cost the same as AWS EC2 (and possibly more if it adds additional services you do not normally use). It is a PAAS service (Platform As A Service) - so you upload your code and AWS works out what you need to deploy the App.

Lightsail

AWS Lightsail is the cheapest - costs £3.50 a month. It uses a "Light" version of EC2 and charges you more money for extras that you are less likely to use. It uses an Apache Server and already has a MERN environment set up for you ready to use. Simply put you index.html in the apache folder area and you will be able to view it via the public URL. You are limited and you cannot deviate out of your environment, but it easily caters for a MERN stack website. You can register with a domain and manage it easily on their. Think of AWS EC2 as a Morgage (you can do what you want), and AWS Lightsail as a Rental property - you are limited but you have what you need. Note that if you want to add a database, you are limited to MySQL or Postgres and you will have to pay extra for it.

Amplify

AWS Amplify costs the same as EC2, as like Elastic Beanstalk it works out what you need (PAAS) to run the app. I personally prefer Amplify as you can set up it up to build and deploy you REACT application in one command. Where as Elastic Beanstalk you have to build it yourself, zip the build file and manually upload it. There is a Elastic Beanstalk CLI but I have not tried it out yet.

AWS Lambda + Netlify

You cannot use AWS Lamdba to host webapps. But you can use Services like Netlify with Lambda to create a serverless Full Stack app. That way you would only pay for the static hosting of the site (free on Netlify), the execution of the lambda functions and the hosting of the DB. Lambda allows you to run functions and is "serverless" and cheap, but it cannot host. Lambda functions can be invoked from other Web Applications though - which can be useful but I don't imagine it is used much for websites. They have their on DB solutions or you can connect to MongoDB cloud (if you want to use MongoDB).

Heroku

Heroku is a PAAS like Elastic Beanstalk but uses Docker Containers to make it service cheaper. But there is a technological cost to set it up. The service costs £7 a month (for every website you deploy) but it is very easy to use and you can link it up to your github (like you can with Netlify), so that it automatically deploys inside the container every time you make a git commit. The free tier puts you App to sleep after an hour so is not much use. It also sorts out a SSL for you, which is an added bonus.
A downside is that it only support Postgres and Redis out of the box. Prosgres is free on hobby plan - only 20 connections at once though and a max of 10K rows, which is fine for small sites. See: https://www.heroku.com/pricing
If you need to use MySQL then you need to look into the ClearDB MySQL add on.

How does free Heroku works
1 acc = N apps (sites)
Each app goes sleep (idle) after 30 mins if no usage
1 acc has 1000 dyno hours/mon
1 dyno hour = 1 hour site is online. Just anyone who will open your site makes it run again
If you open site for 1 sec with 30 mins interval 10 times you will use 5 dyno hours
To not make site sleep you can use site monitor like New Relic. It will check site availability by pinging it and will make it online each 15 mins (before Heroku will make it sleep). Here is the article on how you can setup it.
No visitors limits

Render

A mix between Netlify and Heroku but simplier. Static sites are free, but you can also have backend for 7 pound - supports Node, Python, Go, Rust, PHP, Laravel and more. You can pay 7 pound for database services too.

Azure

Virtual Machines

The VMs on azure are not that different to the EC2 pricings.

Web Apps

This is a lot more expensive, about 30 pound a month on the lowest tier. It works like Heroku in that it spins up docker containers. But you do have a lot more flexibility and power with Azure. Deployment to Azure WAs are normally done (recommended by Azure) using Github actions, which most of the time is free - but can cost a lot if deploying lots. More suited to larger applications and companies.

Google Cloud

https://cloud.google.com/solutions/web-hosting

Google cloud can be cheaper than AWS generally apparently: https://kinsta.com/blog/google-cloud-hosting/#pricing

Top comments (0)