How to create a 3-tier architecture with a load balancer

This how-to explains how to create a 3-tier architecture for WordPress. It will include a load balancer with two front-end servers, one for the admin section and another one for the public section, and a database in a private subnet.

Architecture

Wordpress will be accessed using the DNS name of the load balancer. If the user tries to access the private section, the load balancer is going to use one of the servers, in case of the public section, it is going to use the other server.

Prerequisites

  • Have a VPC in the region where the 3-tier will be created. This VPC should have 2 subnets, one public and one private. The steps to create are explained in How to create a VPC with default subnets. VPC created
  • Have different templates with the WordPress cookbook created to be used for every tier of the architecture. One template with the frontend cookbook recipe and the other with the database cookbook recipe. For this example, you will be using one that you can download from here. Database template created Front-end template created

Create the database in private subnet

  1. Go to Compute -> Servers. Servers section
  2. Select the "Add server" option in the "Add server" selectable. Servers creation select
  3. Provide all mandatory fields and press the "Add server" button. It is important to select the database template as Template, the VPC created in prerequisites as VPC, the private subnet as Subnet and check the option Private. Database server creation pop-up
  4. Wait until the server is in the "Inactive" state and then boot it.
  5. Wait until the server is in the "Operational" state. Database server created

Create the front-end in a public subnet

  1. Modify attributes of the cookbook in the front-end template to add the back-end server IP address. Template front-end attributes modification
  2. Go to Compute -> Servers.
  3. Select the "Add server" option in the "Add server" selectable.
  4. Provide all mandatory fields and press the "Add server" button. It is important to select the front-end template as Template, the VPC created in prerequisites as VPC, the public subnet as Subnet. Frontend servers creation pop-up
  5. Wait until the server is in the "Inactive" state and then boot it.
  6. Repeat the previous steps to create another server.
  7. The servers have been created and they are running. Frontend servers created

Create a load balancer

  1. Go to Network -> Load balancers. Load balancers section
  2. Press the "Add load balancer" button.
  3. Provide all mandatory fields and press the "Add load balancer" button. Load balancer creation pop-up
  4. Wait until the load balancer is in the "Applied" state. Load balancer created

Create a target group

  1. Click on the name of the load balancer to view the details. Load balancer details
  2. Go to the "Target groups" tab. Target group section
  3. Press the "Add target group" button.
  4. Provide all mandatory fields and press the "Add target group" button. Target group creation pop-up
  5. Wait until the target group is in the "Applied" state.
  6. Repeat again the previous steps to create another target group.
  7. Target groups have been created in the load balancer. Target group created

Create a listener

  1. Click on the name of the load balancer to view the details.
  2. Go to the "Listeners" tab. Listener section
  3. Press the "Add listener" button.
  4. Provide all mandatory fields and press the "Add listener" button. Listener creation pop-up
  5. Wait until the listener is in the "Applied" state. Listener created

Add rule to listener

  1. Click on the name of the listener to view the details.
  2. Press the "Add rule" button.
  3. Provide all mandatory fields and press the "Add rule" button. Rule creation pop-up
  4. Wait until the listener is in the "Applied" state.
  5. Repeat again the previous steps to create another rule.
  6. Rules have been created in the listener. Rule created

Add servers as a target of a target group

  1. Click on the target group to view the details.
  2. Select the "Add server" option in the "Add target" selectable. Server creation select
  3. Select the server to add and press the "Add server" button. Server creation pop-up
  4. Wait until the target group is in the "Applied" state.
  5. Repeat again the previous steps to create another target group.
  6. The servers have been added as a target to the target group. Server add as target

Additional Resources

Chef cookbooks Wordpress Multitier architecture