DEV Community

Cover image for High Traffic WordPress website with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series
Salman Sohail
Salman Sohail

Posted on • Originally published at salzam.com on

High Traffic WordPress website with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series

This series will help you with setting up Dockerized WordPress website on you local machine and fully automate the deployment process to Amazon Web Services.

The website will be ready for heavy traffic. To achieve this, I have created the following topics:

I know it sounds a bit harsh saying that WordPress is not civilized enough for AWS but hear me out !

I have been working with modern frameworks such as Rails, Laravel and reactJS for some time now. All these frameworks have evolved so much overtime and ready for multi environments, CI/CD, Load balancers and the list goes on.

Our main product is built on Rails and its fully automated with AWS CI/CD and other automation. Sound great isn’t it?

We recently decided to separate our behind the paywall application and content from each other. In simple words, our complex application (built in Rails) will stay as it is. On the other hand, for content such as blog, marketing pages and few other things such as recipes will be on WordPress.

I will take you through the journey of the whole process and lessons I have learnt during this process of making WordPress shine on AWS with CI/CD, Load balancers and how much WordPress is not ready for that transition by default.

So Let’s make WordPress up its game !

Let’s begin with the challenges I have faced and then you can make the call if these are the right series of tutorials for you or not.

1 | Load balancer and bloody plugins

We all love the fact that on WordPress, we can install plugins without a deployment. Here’s the challenge with this approach, if your WordPress website is behind a Load balancer and there are multiple instances running. You will be installing the plugin only on the instance you are connected to. It will crash for the users who are connected to other instances.

One simpler solution is to deploy the WordPress website again with the plugin included. It takes away the freedom of installing or un-installing a plugin without a redeployment.

AWS Elastic File System (EFS) is our answer, we will simple mount the plugin directory of WordPress instances to our EFS. Please take a look at the diagram below:

AWS EFS is not just highly available, its IO operations are blazing fast. Don’t worry it won’t slow your website down at all.

2 | Centralized MYSQL Database

Most of the people are probably using AWS RDS already with their WordPress websites. We will be using the same too. Just a centralized database for WordPress website behind Load Balancer.

3 | De-couple variables stored in Database and DO NOT configure the Apache or Ngnix every time

Simple as it sounds, variables such as SITE_URL will not be stored in MYSQL database. You know we always have to configure Apache or Ngninx for the wordpress websites.

A lot of people create/use Amazon Machine Images (AMI) for that purpose. the only problem with using AMI is configuration changes. You will have to create a new AMI on every change you make. Damn what a waste of time.

We will have a boiler plate WordPress Docker template which can kick start any WordPress website in minutes without configuring Apache, Ngnix and other settings.

4 | Website performance and SEO challenges

There are so many plugins available for WordPress website performance boost. I will share the ones I have used and what have worked for us in the end.

5 | AWS Elastic Container Service

Finally, How to use Amazon Elastic Container Service which includes the following:

  • Amazon Elastic Container Registry (ECR)
    • Our Docker build repository that contains our most recent Dockerized WordPress project with all the server configurations
  • Amazon ECS Task Definitions
    • This is where we use our Docker build and put all the variables for our WordPress website; Remember we’re not keeping our website variables in the database.
  • Amazon ECS Clusters
    • This is where it creates the EC2 instances of your WordPress website using the ECS Task Definitions.

Next

Dockerize WordPress with themes, plugins and common configuration

Oldest comments (2)

Collapse
 
jsidney profile image
Jonty Sidney

Loving this architecture and implementation!!! Seriously a life saver for myself and a client doing a large scale Wordpress implementation :)

One question --- is there any ETA on the CodePipeline post? One of our big issues is rolling deployments (CICD) for our Wordpress sites. I am super interested in seeing how you approached this !!

Collapse
 
wywarren profile image
Warren Wang

Are you doing any special setups for the EFS? Based on many articles and personal experience setting this up, it's still significantly slower than running WordPress off of EBS. This is with opache enabled as well. Would like to hear other's experiences.