What will happen to the EBS data when autoscaling the EC2 instance

amazon ec2amazon-ebsamazon-web-servicesautoscalingload balancing

I have various websites hosted on 1 same single EC2 instance so far. In the root EBS volume of such instance I have:
Codes and files of the websites which change every hour if not every minute
Apache and PHP configuration information which I change every one to two week for on-going development e.g. modifying the virtual hosts.

I would image autoscaling works the following way:

  1. When traffic to my websites spikes and CPU ultilisation goes above 70% (my Cloud Watch settings), 1 more EC2 instances are spawned
    These newly spawned EC2 will have latest codes & files in my original EC2 instance
    During the time that the additional EC2 instances run, codes & files are kept consistent/ synchronised.
  2. When CPU ultilisation goes below 40%, additional EC2 instances are stopped/ terminated (which ever accommodate 3. below)
  3. When CPU ultilisation is above 70% again, additional EC2 instances are started (if they were stopped in 2.) or spawned (if they were terminated in 2.) with same requirements as 1.)

I've done searches and found tutorial such as this suggesting that I need to create an AMI first of all.
Wouldn't I lose data consistency because of such approach?
Can the AMI be created when traffic spike arises and can the data be kept consistent?

Best Answer

Your data on your first instance will not carry over to other instances. You will have to create a custom ami and bootstrap your instances if you want to autoscale. For example, you can keep a copy of your production files on S3 and have the instances look at S3 for the files on startup and periodically after startup. For files that are changing every minute, you may want to consider hosting them outside your instances, like on S3.