Editor choice

WordPress Infrastructure Architecture

For a lot of WordPress developers and users it’s easy to take for granted the infrastructure needed to run your WordPress website. WordPress makes it so easy to setup from the beginning and if you are using a good hosting provider, it’s even simpler. But if you are self-hosting WordPress you really should understand the WordPress Infrastructure Architecture. WordPress infrastructure can be deployed in several different ways. We’ll explore different architectures for hosting WordPress and the pros and cons of each. Although WordPress can be installed on many different Operating Systems, including Windows and Macintosh, we’re going to focus on Linux infrastructure. Linux deployments are by far the most common, and usually have a cost and performance advantage.

WordPress Infrastructure Architecture

WordPress Architecture Components

WordPress is relatively simple when it comes to infrastructure requirements. It is commonly referred to as a LAMP stack application. Linux, Apache, MySQL, PHP. From an infrastructure perspective these roll up into three distinct  components:

  • Web Server – This is the Apache in LAMP. The Web Server is responsible for executing the WordPress application and sending responses back to the user’s web browser.
  • Database  – This is the MySQL portion of the stack. WordPress stores a majority of its content inside the database. The database content is very important to WordPress. If there’s an issue with the database it will impact the whole website.
  • File Content – The PHP part of LAMP comes into play here. The base WordPress installation, Themes, and Plugins all reset on your server’s file system and are access by the web server. While the setup is simple, this portion can limit your ability to scale later on.

Single Tier Architecture

Wordpress Single Tier Infrastructure Architecture

Probably the most common WordPress Infrastructure Architecture, the single tier architecture is simply a single server. Apache and MySQL are both installed on the server. The WordPress install is placed in /var/www/. For most self-hosted WordPress sites the single server is a Virtual Server deployed in a Cloud Provider. For sites with low to medium volume traffic, this solutions will work well. This architecture is very easy to deploy given that everything is local to one server. This also keeps the cost down. A small Linux virtual server can easily host several small WordPress sites, and the cost from Digital Ocean for example is $5/month.

The downside is that this architecture does not scale well and will not handle high volumes of traffic. With everything on one server, the only option you have is to resize your virtual server, adding more CPU and Memory. Scaling up your web server will buy you time, but if your traffic continues to grow you will not be able to continually scale up to meet growth.

Some popular cloud providers for Virtual Servers are:

Read our recent comparison of Cloud Provider Storage Performance.

PROS:
  • Very Low Cost
  • Fast and Easy to Setup and Support
  • Can Scale Up

CONS:
  • Does Not Scale Horizontally
  • Can Not Handle Large Volumes of Traffic
  • Is a Single Point of Failure, a Server issue can bring down the Website

Two Tier Architecture

Wordpress Infrastructure ArchitectureThe Two Tier Architecture is typically deployed for WordPress sites that experience moderate to traffic or may have traffic spikes. In the Two Tier Architecture, two virtual servers are provisioned. A Web Server, that hosts Apache and a server that hosts MySQL. By splitting the Web Server component and the Database component onto different servers, each server’s resources are dedicated to that service. MySQL processes do not have to compete with Apache processes for resources. The Two Tier Architecture has the following Tiers:

  • Web Server Tier
  • Database Server Tier

This WordPress Infrastructure Architecture scales much better than the One Tier Architecture. It can handle sustained moderate traffic, as well fairly large spikes in traffic. Also by moving the database to a separate server, you can improve the security of your environment. It costs more, but given that it’s only two servers the cost is still reasonable. The setup and configuration is more complex given that you need to connect the Web Server to the Database server over a network connection. As traffic grows on your website you still have to scale up your two servers to meet the load. However, even though this architecture is already scaled out some, you don’t have the ability to continue to scale out.

PROS:
  • Separate Web and Database Tiers
  • Can handle medium levels of sustained traffic
  • Moderately priced
  • Separation of functions is more secure

CONS:
  • More Complex Configuration
  • Longer to Setup
  • Cannot Continue to Scale

Three Tier Architecture

Wordpress Infrastructure Architecture

WordPress websites with high traffic will want to take advantage of the Three Tier Architecture. The Three Tier Architecture is also a good WordPress Infrastructure Architecture solution for hosting multiple websites. If you have many WordPress websites to host, instead of building a lot of Single Tier servers, you can build one Three Tier environment and create some economies of scale in your hosting. In the Three Tier Architecture, the MySQL database is on a dedicated server, the Web Server content is mounted to a separate server, and there are multiple servers running the Apache web server. This creates the following Tiers:

  • Web Server Tier
  • Database Server Tier
  • File Content Tier

In WordPress, the MySQL database and File Content are the two application resources. By placing each of these on a dedicated tier the Web Tier can now scale horizontally. We can add multiple Web Servers that are load balanced, and spread our user load across multiple servers. As load increases, we can continue to add servers to the Web Tier. Also because we have no application resources stored on the Web Tier, we could easily expand and contract servers based on load using automation tools. In a pure Platform as a Service provider like Digital Ocean, we would use a solution like HAProxy. In Azure or AWS, we can leverage their native platform load balancing.

The database would run on a dedicated MySQL virtual server. All the Apache web servers would make database connections to the MySQL virtual server. An NFS virtual server would be configured with a file share that will host the Apache website root. Each Apache web server would mount the NFS file share. If you’re using AWS, a good solution would be to leverage AWS EFS to store the WordPress content without needing to manage an additional server. In Azure, using the File Storage service would be a good solution as well.

PROS:
  • Web Tier Scales Horizontally
  • Can Handle Large Traffic Volumes
  • More Easily Upgraded

CONS:
  • Complex Configuration
  • More Expensive Server Hosting
  • Database and File Tiers can only scale vertically.

Fully Scalable WordPress Architecture

Wordpress Infrastructure Architecture

Websites expecting very high volumes of traffic or who need a highly available website will want to look at a Wordpress Infrastructure Architecture that is highly scalable. This Architecture is one step up from the Three Tier Architecture. It has all the features of the Three Tier Architecture, but with additional options for scaling. Including the following:

  • CDN Tier
  • Web Server Tier
  • Clustered MySQL Database Tier
  • Clustered GlusterFS File Content Tier

Instead of having a single MySQL virtual server this solution makes use of multiple virtual servers implementing a MySQL database cluster. Data is replicated between the two MySQL servers in the cluster, and this allows the database tier to scale horizontally. By having more than one MySQL server, if one server fails the database will still be available.

Much like in the Three Tier Architecture the Web Servers mount a file share that will store the web content. But instead of having a single NFS server, a GlusterFS cluster will be used to provide a multi-node environment for storing the file content. As resources are needed additional GlusterFS nodes can be added to the cluster. This allows for the File Tier to scale horizontally as well as provide high availability if one of the nodes fail.

A Content Delivery Network is used to host static file such as images, Javascript files, and CSS files. The CDN hosts the static files on its servers across the Internet, which users download the files from. Not only does this help improve the performance of your website, but it reduces the amount of storage and bandwidth consumed by your website. Also keep in mind a CDN can be easily incorporated into any of the other WordPress designs above. There’s a number of CDNs that work well with WordPress and also have Free Plans:

PROS:
  • CDN for Static File Offloading
  • Database and File Tiers Scale Horizontally
  • No Single Point of Failure
  • Extremely Scalable

CONS:
  • Very Complex Configuration
  • Very Expensive Server Hosting
  • Greater Administrative Overhead

Hopefully this article provides a good understanding of Wordpress Infrastructure Architecture and the various options available for building your WordPress environment.

I’m an avid Technologist, while I do work on architecting solutions that span from the desktop to the data center, my passion is Web Infrastructure.
We will be happy to hear your thoughts

      Leave a reply