I have an EC2 instance with a web server installed, where several dynamic websites with databases are hosted. I set up an auto-scaling group that launches new instances on high CPU load.
My confusion is that when a new instance is launched by auto scaling, it is completely empty, it does not have a web server installed and has no data from my sites. So when a user is routed to this new instance, he will not be able to see my sites. I thought it should clone the filesystem for new instances to have the same data accessible from all instances launched by an auto scaling group.
So I presume I am supposed to clone my instance somehow to use it for auto scaling and load balancing. So how do I do that? Should I create an AMI from my running instance and use it for my launch configuration and will it contain my websites data? Or should I use something like CodeDeployment and will it be possible to deploy multiple applications (all my websites) and how will this affect instance launch time?
Create an AMI from your configured web site (EC2 instance). Use this AMI in your launch configuration. This is the simplest method for launching new (or replaced) instances with an Auto Scaling Group.
You could also configure your servers on launch, but you will need to factor in how long it would take to install the software, configure everything and wait for the software to come up live. For simple web sites, this can be very quick but for complicated web sites with databases, etc. this could be too long.
When ASG determines that another instance is required, you want the instance to come online as fast as possible. A preconfigured AMI is a good (or best) solution.