Part 1: Deploying WordPress in an AWS Three-Tier Web Architecture – Project Introduction

Introduction

Three-tier architecture with high availability for WordPress.
The three-tier architecture

The three-tier architecture is the most popular implementation of a multi-tier architecture[i].  The architecture is divided into three layers.  The public layer, also known as the presentation tier, is publicly accessible and serves as a shield to the other two layers.  The other layers are the private layers, consisting of the application layer and the database layer.  The application layer, also known as the logic tier, where our program resides, and the database layer, or data tier, which contains our database.

This architecture is very common and has been used for a long time, even before the days of the cloud.  The benefits of using a three-tier architecture include improved horizontal scalability, performance, and availability[ii].

Knowing how practical a three-tier architecture is to host web applications, made it an easy choice to deploy it on AWS using WordPress as the application to be hosted in this project.

About WordPress

WordPress is a free and open-source web content management system[iii].  It was originally created as a tool to publish blogs but has evolved to support publishing other web content, including more traditional websites, mailing lists, Internet forums, media galleries, membership sites, learning management systems, and online stores. WordPress is used by 43.2% of all websites, which is a content management system market share of 63.2%[iv].

 

WordPress Requirements

Software[v]:

  • PHP 7.4 or greater
  • MySQL 5.7 or greater OR MariaDB 10.3 or greater
  • Nginx or Apache with mod_rewrite module
  • HTTPS support

Hardware[vi]:

  • Disk Space: 1GB+
  • RAM: 512MB+
  • Processor: 1.0GHz+

As we can see, the requirements to run WordPress are relatively small by today’s standards.  A three-tier architecture is not required to run WordPress in AWS.

Multiple sources can be found on the web showing how to run WordPress in a single EC2 instance of type t2.micro (1vCPU, 1GB of memory) and 20GB of storage.  For this project, this was the instance type utilized since they fall into the AWS free tier.

Hosting WordPress in AWS can be very simple as many providers sell Amazon Machine Images (AMI) which have WordPress already installed on them through the AWS Marketplace.

 

AMI results from the AWS marketplace offering instances with WordPress.

 

 

 

 

 

 

 

 

 

 

 

If running WordPress on AWS requires so few resources, isn’t a three-tier architecture excessive?

The purpose of building the three-tier architecture is to create a solution that provides increased security, availability, performance, and scalability.

This is achieved by:

  • Security: creating public and private subnets
  • Availability: redundancy in different Availability Zones (AZ) and RDS ([vii]auto switches to standby replica)
  • Performance and Scalability: RDS ([viii]vertical auto-scaling) and Auto Scaling Group (horizontal scaling)

EC2 Instances

For the purpose of the project, the instances used were all t2.micro to take advantage of the AWS free tier.  Seeing how few resources are needed to run WordPress it makes sense to use small instance types from t2.micro to t2.large in conjunction with an autoscaling group that allows our capacity to increase or decrease as needed.

Database

RDS db.t2.micro was used for the project, again, to take advantage of the AWS free tier.

WordPress uses the database to store all your website data.  The MySQL database of a simple WordPress blog is around 10MB.  It is recommended to at least allocate 200MB of storage for the database[ix].  This will vary depending on the site utilization.

AWS offers multiple options to run MySQL.  We can run MySQL in an EC2 instance, RDS, or Aurora.  All these database products have their advantages, disadvantages, and cost variation.

 

Reference

[i] Three-tier architecture AWS.  Retrieved July 7, 2023, from https://docs.aws.amazon.com/whitepapers/latest/serverless-multi-tier-architectures-api-gateway-lambda/three-tier-architecture-overview.html

[ii] Three-tier application architecture.  Retrieved July 7, 2023, from https://www.techtarget.com/searchsoftwarequality/definition/3-tier-application#:~:text=The%20benefits%20of%20using%20a,from%20the%20other%20tier%20developers.

[iii] WordPress – Wikipedia.  Retrieved July 7, 2023, from https://en.wikipedia.org/wiki/WordPress

[iv] Usage statistics of content management systems.  Retrieved July 7, 2023, from https://w3techs.com/technologies/overview/content_management

[v] Requirements – WordPress. Retrieved July 7, 2023, from https://wordpress.org/about/requirements/

[vi] The Ideal WordPress PHP and Server Requirements.  Retrieved July 7, 2023, from https://kinsta.com/blog/wordpress-server-requirements/

[vii] Multi-AZ DB instance deployments. Retrieved July 7, 2023, from https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZSingleStandby.html

[viii] Scaling Your Amazon RDS Instance Vertically and Horizontally.  Retrieved July 7, 2023, from https://aws.amazon.com/blogs/database/scaling-your-amazon-rds-instance-vertically-and-horizontally/

[ix] How big can your WordPress site’s MySQL database get?.  Retrieved July 7, 2023, from https://berkaweb.com/hosting/guides/wordpress-mysql-database-size/#:~:text=Quick%20answer%20for%20beginners%3A%20how,actively%20work%20on%20growing%20it.