- Newest
- Most votes
- Most comments
You need to make the necessary configurations so that when a new instance starts, your application runs. Here I'm going to give you some options:
-
You can create a "launch template" in the "user-data" section you can launch bash commands. Here, for example, you can create a bash script that downloads your project from the repository, then place instructions for downloading the necessary libraries and then the command that starts your server in nginx.
-
Create a custom AMI that contains the necessary libraries and packages and your application is ready to start. Then you create a "lauch template" with the created AMI.
So when autoscaling launches a new instance, the instance will already know how to start your application.
As a tip, I recommend separating the front-end from the back-end so that they can scale independently or even better, move the front-end to S3 and use CloudFront to improve your architecture.
Hi thanks for reaching out!
You'll need a combination of Load Balacing, EC2 and an external database on EC2 or RDS if you want to scale from one instance to multiple instances. Please note that your data tier (database) should be in a separate environment for data consistency and all your web tier nodes should point to that database.
Please make sure that your web tier AMI (Amazon Machine Image) contains all the necessary configurations beforehand, so when Auto Scaling launches the new instances they will come online automatically.
Please have a look at this documentation for Wordpress which explains some concepts applicable to your use case: https://docs.aws.amazon.com/whitepapers/latest/best-practices-wordpress/scaling-the-web-tier.html
I hope this helps.
Both great answers. Another option is to use code deploy to deploy your application to new ec2 instances that start and register. Once your application is running it will become health on the target group and requests will be routed to the new instance.
This negates the need to manage an ami and also helps you deploy new versions to current and future ec2 instances.
https://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-auto-scaling.html
Relevant content
- asked 9 months ago
- asked 3 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 7 months ago
Careful with backend on the instance. When the ASG scales in, the instances will be terminated and any data will be lost unless you setup a way to persist it. Separating out the data to a separate tier as suggested below will help with this. ASG is works simplest with stateless instances