Piecing from things I've researched.
While I'm still developing locally. I'm keep in mind a design and layout a way to orchestrate my personal full stack project on production. Fundamentally its just a website + an api server + postgres. But, I'm still having trouble with how things should fit together or that I have anything amiss.
In this scenario, I have the Nginx serve my react static build, and an express node.js acting as api server hosted under its subdomain. example: as mywebsite.com and api.mywebsite.com.
- I'll have route 53 -> direct DNS to my ec2 instance.
- EC2 nginx will reverse proxy a subdomain into local servers for api, while it serves react/build folder on plain domain.
- pm2 is in place to maintain node.js online status + clustering will add a bit of horizontal scaling between unused vCPU.
- node express connects privately to RDS via VPC.
- Include service manager setup within systemd, so whenever EC2 restarts, everything will return back online without much interaction.
uncertainties: This sure is a lot of setup, and many nuisance between different OS/distros (i.e. systemd/launchd ) - is this the reason people dockerize their projects?
With the free tier t3.micro operating on 2vcpu...does this means my pm2 cluster mode would use both cpu.. and does this hinder nginx performance (or kernel will balance it with little no none efficiency loss)?