I am relatively new to Amazon Web Services and I am trying to get my head around how Elastic Load Balancing will work in context of my wordpress setup. In addition, I would like some advice on proposed infrastructure.
My initial proposed infrastructure is as follows:
- 1x EC2 m1.small – Ubuntu 12.04.3 LTS 64bit (with 1 EBS volume)
- 1x EC2 t1.micro – Ubuntu 12.04.3 LTD 64bit (with or without EBS volume?)
- 1x Micro RDS Instance – MySQL 5.6.13
EC2
My current EC2 (t1.micro) is running a LAMP stack and configured to run wordpress.
I would like to load balance this with an m1.small instance, running a clone of the t1.micro instance.
The current unknowns for me are as follows:
- How will a load balanced setup manage changes made on the wordpress CMS across instances? Will I have to keep updating the AMIs every time a change is made in wordpress?
- My website is an ecommerce website. Is there any impact of this in a load balanced setup? I.e., is there a possibility for orders to exist on one instance and not another?
It might be a pretty stupid question, but I am presuming some issues won't be relevant because the infrastructure is referencing one database.
Lastly, is there a better way I should be setting up the infrastructure for load balancing? I.e. should I be considering using Amazon S3 to store all of my files and use Cloudfront as a CDN to ensure efficient operation and resolve any EBS file replication issues.
Any help greatly appreciated.
Lloyd
Best Answer
Stateless web apps are hard.
As you know, wordpress relies pretty heavily on things being written to disk. Here is the proposed infrastructure
Now the hard part.
Lets forget about updates to the codebase for a second and lets look at how to make the whole thing stateless. You should do the following to make this thing horizontally scalable:
This takes care of the setup
How to deploy new changes
You will use your micro instance for all future changes to the wordpress install. This includes stuff like updating wordpress, updating your theme files and pretty much anything that is stored on the disk.
You will need to create two scripts:
The first one will be used to deploy the changes to the autoscaling group. It should do the following:
The second script will live on the auto-scaling group's instances and be triggered by the first script as well as run when the instance is initialized for the first time. It should do the following:
Each time you make any system file changes, you should run the deploy script above. this will then propagate the changes to all the production instances.
Now create a base AMI for the production instances. It should be very very similar to the micro instance however wordpress should not actually be installed. You will use userdata passed into the ec2 instances on launch to run the second script above to download the latest version of the codebase from the micro instance.
One last thing... If you are running any form of e-commerce you are going to need an SSL certificate installed on the load balancer. have a look at the guide here: http://www.nczonline.net/blog/2012/08/15/setting-up-ssl-on-an-amazon-elastic-load-balancer/