DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Wordpress on AWS: Smooth and Pain Free

Wordpress on AWS: Smooth and Pain Free

Like it or not, Wordpress publishes about a quarter of the websites out there. If you're taking the plunge, you might as well make it scalable and fault tolerant.

Andreas Wittig user avatar by
Andreas Wittig
·
Nov. 02, 16 · Cloud Zone · Tutorial
Like (1)
Save
Tweet
4.19K Views

Join the DZone community and get the full member experience.

Join For Free

I’m not a fan of Wordpress, as it is neither cloud-ready nor serverless. That’s why this blog runs on CloudFront and S3 and is built by Hexo. But 25% of all websites are proudly published with Wordpress. You will learn about the easiest way to run Wordpress on AWS. Including fault tolerance and scalability.

The following figure shows the architecture of a fault tolerant and scalable Wordpress environment on AWS.

Wordpress on AWS

Read on to learn more!

The Problem

Wordpress is a PHP application using two different data storages: a MySQL database and files on disk. Storing files on disk is a problem if you want to make use of a fleet of EC2 instances to run Wordpress in a fault tolerant and scalable fashion.

The following example and figure are illustrating the problem.

  1. Mary is uploading a new image for her blog post. The image file is stored on EC2 instance number 1.
  2. Mary is reading through her article. EC2 instance number 1 is answering her HTTP request to get the image.
  3. Bob is reading Mary’s article. EC2 instance number 2 is answering his HTTP request with a 404 Not Found error, as the image is stored only on EC2 instance number 1.

Wordpress stateful server

Tricky, you need to find a way to either synchronize files between all EC2 instances or outsource the files to a managed service.

The Solution, First Try

I tried to solve the problem of running Wordpress on AWS before. Wordpress on AWS: you are holding it wrong describes the solution in detail.

To summarize it briefly:

  • Using a Wordpress plugin to store user uploads like images on S3 instead of storing them on disk.
  • Disabling all other Wordpress features that are writing files to disk: install and update plugins or themes, the auto-updater, and writing a .htaccess file.
  • Automating the process of installing Wordpress with all of its plugins and themes during the boot process of each EC2 instance.

But not being able to install plugins and themes and to use the auto-updater is inconvenient.

The Solution, Second try

The Elastic File System service (EFS) joined the AWS family in January 2016. EFS is a highly available and scalable network file system that you can connect to your EC2 instances by using the NFS protocol. The perfect place to outsource files.

The following figure shows how each EC2 instance running Wordpress is connecting to EFS to read and write files. You don’t need to distinguish between user uploads and files belonging to Wordpress itself.

Wordpress with EFS

As a network call is necessary every time your EC2 instances want to read a file from EFS, it is important to have file caching in place.

Especially for .php files, as Wordpress needs to access a lot of .php files for each incoming request. Something you can solve with opcache quickly.

Caching static files is necessary as well. Because each visitor of your Wordpress blog will need to load the same .css and .js files a CDN like CloudFront is a perfect fit.

The following figure shows the complete architecture of Wordpress on AWS based on these services:

  • CloudFront: CDN for dynamic and static content.
  • ELB (Elastic Load Balancer): load balancer forwarding requests to EC2 instances and terminating SSL.
  • EC2 (Elastic Compute Cloud): virtual machines running the web servers
  • EFS (Elastic File System): storage for Wordpress files (Wordpress core, plugins, themes, and user uploads).
  • RDS (Relational Database Service): MySQL database.

Wordpress on AWS

The Deployment

Do you want to run Wordpress on AWS by using EFS as described above? I have created a CloudFormation template that you can use to create the needed cloud infrastructure within minutes including the following features:

  • Reliable: Fault tolerant and scalable due to multi-AZ usage
  • Secure: HTTPS only
  • Fast: CDN caching static content
  • Growing: scalable file storage for endless user uploads

Learn more about the CloudFormation template for running Wordpress on AWS and launch your stack within minutes.

AWS WordPress File system

Published at DZone with permission of Andreas Wittig. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Classification of Neural Networks in TensorFlow
  • What Is Selenium? Getting Started With Selenium Automation Testing
  • Making Your Own Express Middleware
  • Java Microservices: Code Examples, Tutorials, and More

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo