Start with your database. This is the powerhouse for your WordPress site. You don’t need a massive store, so use
RDS. The next question is which database to provision. Your best choices here for WordPress are
MariaDB,
MySQL or
Aurora (in MySQL mode). Aurora will cost you about 2.5 times the other two, but is seriously robust and performant. Which you choose will depend on how business-critical your site is.
Create a new VPC subnet for your Wordpress stuff, and launch your database instance into that subnet, with no public IP address. Think of a name for this database instance, and set up a DNS name to point to its private IP address. Configure the database and tables you’ll need. You may need to attach an Elastic IP temporarily, but remember to remove it when you’ve finished: you don’t want your DB world-visible.
Next, start any old EBS-backed EC2 instance type within your WP subnet, and set up WordPress on it. This one will have a public IP address. Whether you use a pre-cooked Marketplace AMI or start with a basic Amazon AMI and add your own packages is up to you. Configure your WP instance’s WordPress setup to connect to your database instance using the DNS name, rather than using a local database.
Set up the rest of your WordPress installation. Put your fixed assets into S3, not locally, and reference them using their S3 URIs.
Test it all works, and that you can use your site from the outside world.
Now save your WP instance as a private AMI.
From now on, you can launch a new instance from this AMI, and point your website domain name to it. If the instance is too small, use the AMI to template a bigger one, point the website domain name to that, and terminate the smaller one. (Your assets are in S3, and your database isn’t on that instance, so you’re safe to do this!)
If you find you need a more flexible approach, create an Elastic Load Balancer that can launch more instances at need, shut them down when loads dwindle, and distribute the workload amongst them, and point your website domain name at the ELB instead.
Finally, if you find you need to do updates (security, etc.) on your WP installation or its operating system, create a new instance from the AMI, make the changes, save a new AMI, and tell your load balancer or DNS configuration to use this instead. Keep the old AMI around for a while in case the new config breaks things.
Oh, and do back up your database from time to time, but that’s a different answer entirely.
No comments:
Post a Comment