Phate
Phate

Reputation: 6602

How to properly configure a web application instance with autoscaling?

Last day I wanted, according to AWS recommendations, put my ec2 instance inside of an autoscaling group. I created my ec2 instance by using the standard linux AMI instance and then I installed a full LAMP server. The next morning I tried accessing my apache and guess what? My LAMP wasn't there anymore! Everything was wiped away.

I guess this is because, for some reason, the autoscaling group deleted my instance and recreated it vanilla.

Now I still want to autoscale my instance but, of course, I want to keep my LAMP and the stored data. So here's my questions:

  1. How to create a customized image starting from my actual instance?
  2. Would it be correct to create the mysql DB using AWS RDS so to not keep it linked to my instance?Is it more or less expensive than dedicating a EBS storage?
  3. I also want to keep my /var/www/html data somewhere shared between instances: while it is true that, on production, I won't update those files often it is also true that I don't want to lose them just because the autoscaling resets my instance state. I also don't want to re-create an image each time I update said files... What's the best way?Maybe an s3 bucket? Or, still, an EBS storage shared between instances?

Upvotes: 0

Views: 86

Answers (1)

jarmod
jarmod

Reputation: 78573

I would assume that the reason that your "LAMP [server] wasn't there anymore" was because the web server failed health checks and was terminated and replaced by AutoScaling.

Elastic Beanstalk would be a good way to manage some of the complexity here. If that's not an option then you should read up on AutoScaling, ALB, and health checks.

In response to your specific questions:

  1. you can create an Amazon Machine Image (AMI) from an instance. When you, or AutoScaling, launch a new instance from that AMI, you can get the instance up to date by running a script in userdata
  2. move the DB from the web/app server to RDS, or to a DB server that you manage yourself
  3. maintain the html/js/css etc. in S3 and sync them to your web server periodically (there are other options, but that's simple)

Upvotes: 2

Related Questions