container vs VM for monolith application
Hi everyone, so I'm planning to build a SaaS app since the job market isn't that spectacular, however I have little experience (actually none-I'm "self taught") with deploying productions apps, server performance and costs . I plan to build the app using monolithic architecture but I'm not sure what is the best way to deploy it cost effectively, I have deployed containers on EC2 and ECS before for practice projects and I liked how you can spin up multiple containers to handle request spikes with a load balancer, but at the same time I read that containers are better suited for microservices, the app that I plan to build is an ERP that should have 10,000 users per month. So what I need to understand is 1. if I were to deploy the entire app on an EC2 instance with db hosted separately and no containers , will the app handle the traffic since I wont be setting up a load balancer? 2. will it make sense to deploy a monolith using containers so as to incorporate load balancing( i.e by creating multiple instances of the app and using nginx to round robin through the container instances)?...lastly I'd be thankful for any advice from anyone who has deployed production applications before on how to approach this. Thanks
22 Replies
Would those 10k users be using it at the same time? Normally distributed throughout the month? Clump together during certain times?
Unless you get spectacularly lucky, you won't have explosive user growth that you can't keep up with. If the product is successful you'll see user numbers grow and based on that growth have an idea of when you need to address scaling problems. In the beginning I'd prioritize whatever is easiest for you to understand and maintain
which languages and tools/frameworks will you use?
what's the tech stack?
Would the answer change the recommendation for how to deploy things?
obviously
you wont shove php in versel
or try to run ruby on rains in netlify
or try to run python in a php hosting server
also, the way each language and platform handles many requests is important to know
for example, php-fpm would need more pools to handle over 1024 users at a time
and if it is 10k concorrent users, a load balancer might be a good idea
also, it would be a lot easier to throw everything into vercel than to handle all this server stuff by yourself, if you use javascript
The original question was about EC2/ECS, but fair point, expanding it to other providers the stack will matter
yes, a container in aws or something isn't always the best or most cost effective solution
for php, there's way cheaper solutions
as well as for javascript
if it is a conglomerate of micro-services, maybe containers in aws will be a better solution
I can't imagine a solo dev going all in on micro-services, unless it's purely a learning exercise
but back on topic, @John Patrick Onyango what stack are you planning to use and how committed are you to AWS?
i can see it, in some cases
a micro-service that just handles images
another one just for handling uploads from users
other one just for authentication and user settings
but yes, the tech stack is more important
postgres, nestjs,redis for the backend, next js and tailwind on the front end
most of the users would use it actively during the first week of the month because that's when payments is made, but yes, i suppose you are right. I will rent a cheap VM from digital ocean for starters
wouldn't vercel be enough too? they have a very generous free tier
AWS hasa good free tier for ECS, but I m open to other options
vercel is very good for fronted, i have never deployed a backend to vercel though
plus i do not want to have more containers than users 🙂
i've never deployed to it, as javascript isn't a language i use on the backend
what do you use for your backend?
php
it has the advantage of being stupidly easy to deploy for very very cheap in very competent servers
you just throw the files in and it's done
also, server-side rendering is growing a lot more lately, so, js backend "frameworks" have been implementing it - which is 100% how php works
php with laravel or just vanilla php?
yes
and wordpress too, because the cms already exists
but i prefer pure
fwiw, my backend is in go, I was able to deploy it to fly.io without issues, YMMV
their free tier is very limited though, no more than 3 machines, and only 256MB of ram each
php is nice but the dollar sign syntax is a real pain, but yes, php is easy to use and quite powerful, I recently build a backend API with vanilla php without any libraries and it was easyyy
atleast they have unlimited free tier VMs in the first place, I'll check that out
it is really easy
and did they reduce the garbage collector "lag"?
Not sure what you mean by unlimited, I suppose you can run them indefinitely as long as you stay under https://fly.io/docs/about/pricing/#free-allowances
thanks, I'll check this out
Let us know what you end up using for deployment/how it's working out