DEV Community

Cover image for Deploying a Highly Available 3-Tier WordPress Architecture on AWS with VPC, ALB, EC2, RDS, and EFS
Bilal Bukhari
Bilal Bukhari

Posted on

Deploying a Highly Available 3-Tier WordPress Architecture on AWS with VPC, ALB, EC2, RDS, and EFS

WordPress powers a large share of the web, but running it reliably in production takes more than launching a single server. Recently I designed and deployed a traditional 3-tier WordPress architecture on AWS for a client. The goal was a setup that is secure by default, resilient to the loss of an Availability Zone, and straightforward to maintain.

This article walks through the architecture, the key build steps, and the design decisions behind them.

Architecture Overview

The environment is built around three logical tiers, spread across two Availability Zones in us-east-1:

  • Presentation tier: an Application Load Balancer (ALB) in public subnets, receiving all inbound traffic [1].
  • Application tier: EC2 instances running WordPress in private subnets.
  • Data tier: an Amazon RDS MySQL database in dedicated private subnets [6], with Amazon EFS providing shared storage for WordPress content [5].

Architecture diagram of the 3-tier WordPress deployment

The network is a single VPC (10.0.0.0/16) divided into six /24 subnets:

Subnet CIDR Tier AZ
Public subnet 1 10.0.0.0/24 Public (ALB, NAT Gateway) AZ 1
Public subnet 2 10.0.1.0/24 Public (ALB, NAT Gateway) AZ 2
Private subnet 1 10.0.2.0/24 Application AZ 1
Private subnet 2 10.0.3.0/24 Application AZ 2
Private subnet 3 10.0.4.0/24 Database AZ 1
Private subnet 4 10.0.5.0/24 Database AZ 2

Separating subnets by tier gives clean security boundaries: the database never shares a subnet with anything that faces the internet.

Step 1: Building the Network Foundation

I started in the VPC console and created a custom VPC rather than using the default one, so that every CIDR range and routing decision is deliberate.

VPC service in the AWS console

Each subnet was created with an explicit name, Availability Zone, and CIDR block inside the VPC range. Every subnet lives entirely within one Availability Zone, which is why spreading subnets across two zones protects the application from the failure of a single zone [2]. Consistent naming (PublicSubnet1, and so on) pays off later when you are selecting subnets in the ALB, EFS, and RDS wizards.

Creating a subnet

The diagram below shows how the subnets, route tables, and tiers relate to each other in each Availability Zone.

Subnet and routing layout per Availability Zone

Step 2: Routing

Routing is what actually makes a subnet "public" or "private". A subnet is public when its route table sends internet-bound traffic to an internet gateway [3]. I created three route tables:

  • PublicRouteTable: routes 0.0.0.0/0 to the Internet Gateway and is associated with both public subnets.
  • PrivateRouteTableAZ1: routes outbound traffic through the NAT Gateway in AZ 1, associated with the AZ 1 application and database subnets.
  • PrivateRouteTableAZ2: the same pattern for AZ 2.

Creating the public route table

Route tables overview

Using one NAT Gateway per Availability Zone, with a matching private route table for each, means a failure in one AZ does not cut off outbound connectivity for the other. AWS recommends this pattern: resources in a given AZ should use a NAT gateway in the same AZ, so an outage in one zone does not affect the other [4]. The trade-off is cost, since NAT Gateways are billed hourly, which I come back to below.

Step 3: Shared Storage with Amazon EFS

When WordPress runs on more than one instance, uploads and plugins must be available on all of them. Otherwise a media file uploaded through one server simply does not exist on the other. Amazon EFS solves this with a shared, elastic NFS file system [5].

Creating the EFS file system

I created mount targets in both Availability Zones and attached a dedicated security group (EFSSecurityGroup) so that only the application tier can reach the file system. Clients connect to a mount target over NFS on TCP port 2049, so the security group must allow that traffic from the instances [5].

EFS mount targets in both Availability Zones

Step 4: The Database Tier with Amazon RDS

For the data layer I used Amazon RDS for MySQL with the Standard create option, so that I could control networking, backups, and security settings explicitly. RDS removes the operational burden of patching, backups, and failure handling that comes with running MySQL on a self-managed EC2 instance, and it supports Multi-AZ deployments as a high-availability option [6].

Creating the RDS MySQL database

The database sits in the private database subnets and accepts connections only from the application tier's security group.

Step 5: Compute and Access

To provision the application servers, I created an RSA key pair for secure access. I chose the .ppk format because I connect from Windows using PuTTY, which does not natively support the PEM format [7].

Creating a key pair in .ppk format

The instance runs Amazon Linux 2023 from the Quick Start AMIs.

Launching the EC2 instance

Once the instance was running, I connected over SSH to install and configure the web server, PHP, and WordPress.

SSH session on Amazon Linux 2023

Step 6: Load Balancing and Final Configuration

With the WordPress instances healthy, I placed them behind an Application Load Balancer deployed across the two public subnets. The ALB is the only component that faces the internet. It distributes incoming traffic across targets in one or more Availability Zones and routes around unhealthy ones [1].

After installation, the WordPress admin dashboard confirmed that the application was running correctly.

WordPress admin dashboard

One detail that is easy to miss: WordPress stores its own address in the database. Behind a load balancer, both the WordPress Address and Site Address should point to the ALB's DNS name. Otherwise redirects and asset URLs can break [8].

WordPress Address and Site Address set to the ALB DNS name

Security Design Decisions

  • Private application and database tiers. Neither tier has a public IP exposed to inbound internet traffic. AWS itself recommends private subnets for protecting resources, with a NAT device providing outbound internet access [2].
  • Security group chaining. The ALB allows web traffic from the internet, the application tier accepts traffic only from the ALB, and the database and EFS accept traffic only from the application tier.
  • Egress through NAT only. Private instances can fetch updates, but cannot be reached directly.

Cost Considerations

A multi-AZ design is not free. The main cost drivers are the NAT Gateways (hourly plus data processing), the Application Load Balancer, the RDS instance, and EC2 compute. For a learning or proof-of-concept environment, I recommend tearing everything down when you are finished, starting with the load balancer, NAT Gateways, and RDS. For production, consider adding HTTPS with AWS Certificate Manager, an Auto Scaling group, RDS Multi-AZ, and AWS WAF.

Key Takeaways

  1. Design the network first. Subnet and routing decisions are the hardest to change later.
  2. Tier isolation is your best security control. Placing each layer in its own subnets makes least-privilege rules simple.
  3. Shared storage is essential for scaling WordPress. EFS keeps uploads consistent across instances.
  4. Managed services reduce risk. RDS handles the undifferentiated work of running a database.
  5. Plan for cleanup. NAT Gateways and load balancers bill continuously.

Conclusion

This project is a solid reference for how a traditional web application maps onto AWS: a public entry point, private compute, and a protected data layer, all spread across two Availability Zones. It also shows why networking fundamentals matter before you touch a single EC2 instance.

If you are building something similar, I'm happy to discuss design choices in the comments. Thanks for reading!

References

  1. AWS Documentation, What is an Application Load Balancer?, Elastic Load Balancing User Guide.
  2. AWS Documentation, Subnets for your VPC, Amazon VPC User Guide.
  3. AWS Documentation, Subnet route tables, Amazon VPC User Guide.
  4. AWS re:Post Knowledge Center, How do I set up a NAT gateway for a private subnet in Amazon VPC?
  5. AWS Documentation, Managing EFS file systems and Using VPC security groups, Amazon EFS User Guide.
  6. AWS Documentation, Amazon RDS for MySQL, Amazon RDS User Guide.
  7. AWS Documentation, Connect to your Linux instance using PuTTY, Amazon EC2 User Guide.
  8. WordPress Codex, Changing The Site URL.
  9. Tech With Lucy, 5 Advanced AWS Cloud Projects: Complete Step-by-step Guide, Project 5: Traditional 3-Tier WordPress Website Deployment on AWS (course used as the basis for this build).

Top comments (0)