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:
- 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.
- When CPU ultilisation goes below 40%, additional EC2 instances are stopped/ terminated (which ever accommodate 3. below)
- 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?