1

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?

3

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.

[EDIT after Tim's comment]

Preconfigured AMI's basically require that your EC2 instances that are auto scaling are "stateless" or download their state on startup (think EC2 Userdata scripts). Databases are generally stateful, so these should be moved outside of the ASG. RDS is a good managed service for databases. The final design needs to consider all of the components and services that your systems provide.

  • 1
    Note that this only works if your servers are essentially stateless, with storage on another service. For example with Wordpress the database needs to be on RDS or another server, and media files need to be on S3 or a shared disk like EBS. Upgrading Wordpress might need a bit of attention as well. – Tim Nov 15 '17 at 7:02
  • @Tim. Thank you. I edited my answer to include the issues that you mentioned. – John Hanley Nov 15 '17 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.