Steps to Configure highly available and scalable wordpress site
This is part-2 of a multi-part series. You may read the first part here if you haven’t already. Here, you will learn how to configure a highly available and scalable WordPress site in AWS.
Select your AWS Region
You will use the AWS management console to implement the topology in part-1. The steps are detailed below. (A video will be provided later to show the step by step procedures). The first thing to do each time you login to the AWS console is to choose your region. Once you have selected your region, check how many Availability Zones (AZ) the Region has. When deciding on the Region to select, decide based on the following:
- Proximity to the target users will make your site more responsive as latencies may be lower
- Compliance and regulatory requirements are important
- Number of AZs are also important as that will affect how much redundancy you can provide for your application. Most AWS AZs have at least 2 AZs with N. Virginia having 5 AZs, the largest so far.
- Cost should also be considered as some Regions are more expensive than the others. The US regions are known to be cheaper than the rest of the world.
- Depending on the services in your Architecture, your choice of regions may be limited as some services are not available in all regions. For some newly introduced services, especially, it can take time for them to be available in some regions.
There are probably a few different ways to start realizing the architecture but starting with the Data-tier will be the most straightforward way, since WordPress installation depends on the Database. Before you create RDS you have to ensure that the networking (e.g VPC and security groups) is in place.
Create the Network Infrastructures for highly available and scalable wordpress site
- Login to the management console and choose your region. Used for for this tutorial is the US_East Ohio which has 3 AZs; US-East-2a, US-East-2b and US-East-2c. If it’s the first time you are using a region, a quick way to see the number of AZs in a region is to click on the VPC section and see the number of subnets listed . This is based on the fact that every region has a default VPC with a subnet in each AZ. In Ohio, you see 3 subnets as shown below, meaning that the Ohio region has 3 AZs. In most other cases, however, you can refer to AWS global infrastructure which list all the Regions and their AZs or better still see the health report status that will list all the available AZs.
2. Create the VPC: You have the option to use the Default VPC to implement your solution but as a best practice you should rather create another VPC. In this way you have more control over your security groups and network ACLs without interfering with any other resources outside of your topology.
- Choose VPC under the networking and Content Delivery section of the AWS management console.
- Click Create VPC and fill out the details with subnet 10.10.0.0/16 and name exampledotcom_VPC1.
After the VPC is created, the following will be created by default:
- A default Route Table
- Default Security Group and
- Default Network ACL
You can view them by clicking on the respective sections on the left navigation.
3. Create 4 private subnets and 2 public subnets (2 private and 1 public in US-East-2a and US-East-2b each). Assign the subnets using /24 CIDR e.g. private subnets Data_VPC1 (10.10.1.0/24), Web_VPC1 (10.10.2.0/24) and the public exampledotcome_pub_2a (10.10.3.0/24). Repeat the process to have 4 private and 2 public subnets.
4. Connect the public subnet to the Internet Gateway (IGW): The difference between a private and a public subnet is that the public subnet has a route to the Internet using the Internet Gateway. To connect the public subnets to the Internet GW, you need to add a route that allows that to happen. Instead of adding the route to the default Route Table created for the VPC, you will create another Route Table.
5. And add the public subnets to the Route Table. You only add the public subnets and not the private ones as you want the private subnets to be unreachable from the Internet.
6. Create Internet Gateway (IGW) so you can reach the Internet
7. And attach it to the VPC that you created earlier
8. Add a route to permit everything from the IGW to the Internet so that the public subnets can reach the Internet.
9. For each of the public Subnets, modify and enable ‘Auto-assign IPs’
Create the Security Groups
Create 3 security groups (web,data and ELB public) for the 6 subnets. Lets call them web_VPC1_secgroup, Data_VPC1_secgroup and exampledotcome_pub_secgroup as shown below. Ensure to do this 2 more times for the other security groups not shown.
Create The Relational Database Service (RDS)
To create a highly available and scalable wordpress site, you now have everything in place to create the RDS database and enable multi-AZ for the RDS.
1.Select launch DB instance and follow the wizard to select MySql
2. Select t2.micro instance and enable Multi-AZ deployment
3. Enter the DB connections details
4. Finally, select the VPC, security group and the DB instance name and leave the rest as default. Note that you did not specify the subnet where the master instance will be created as this is done automatically by RDS. Be patient as it could take a few minutes for the RDS database to be provisioned.
Create an EC2 Instance For Highly available and scalable wordpress site
With the RDS instance created you can now create an EC2 instance with the desired Instance type and choose Amazon Linux AMI. You may also select one of the community images that has the required web services already installed but for this demonstration, you will use a vanilla Amazon machine image and then install our required services.
- Select EC2 and launch an instance with t2.micro and Amazon Linux AMI. Select the exampledotcom_VPC1 you created and select the subnet in AZ US-East-2a
2. Select the web security group
3. Finally, select the keypair and launch the instance.
This concludes part-2 of the multi-part series. Here, you learnt how to configure highly available and scalable wordpress site. Now that the instance is ready, in the next section, you will install WordPress and connect to the RDS database created above. You will then configure WordPress with your theme of choice, install all the needed WordPress plugins along with all customizations and then create an AMI of the instance.