Public Terraform source:
Best practice: https://docs.aws.amazon.com/whitepapers/latest/web-application-hosting-best-practices/an-aws-cloud-architecture-for-web-hosting.html
I saw some mistakes of Full-stack developers about web hosting. To deliver better app should check some points:
- Make sure you optimize the app logic first. (redundancy requests, too much bad interval calling, asynchronous callback handling, crashing loop, heavy process — need split them to smaller logic or put to async response with queue, unsafe type, …….. a lot =]] )
- Design infrastructure before deployment, estimate and make sure the arch scalable, upgradeable, fault tolerance and high availability
- Stress-test and security checking the system before live. (Spoofing email, Leak server IPs, WAF, Rate limiting, Bad url request, user agent, CDN to cache big/static files, ….)
About scaling application, I suggest you should consider about microservices approach:
We should have a separated Database service to control all access to database, do not allow other service access to db directly, it’s suck
And this is a base template for each microservice
This post just share about basic 3 tiers architecture and deploy to AWS Cloud via Terraform script
- Use us-east-1 as main region
- 1 VPC: 10.0.0.0/16
- 2 Availability Zones: 1a, 1b
- 1 Public subnet each zone: Deploy NAT gateway and NAT instance (bastion host) with ASG (Auto Scaling Group), ALB (Application Load Balancing) for Frontend…