1 of 20

HyperScale WordPress in AWS With Docker

@ngineered

@ngineered

2 of 20

HyperScale WordPress in AWS

Deployment + Architecture

Best practices in AWS:

Infrastructure

  • EC2 (Elastic Cloud Compute)
    • CoreOS on AWS

Deployment

  • Storing code in Git
  • The nginx-php-fpm Container
  • RDS (MultiAZ MySQL)

Plugins and PaaS

How to integrate WordPress with AWS:

  • Amazon SES (Simple Email Service)
  • Amazon S3 (Simple Storage Service)
  • HyperDB
  • CloudFront
    • WP Super Cache
  • Google Search
    • Not AWS but still cloud!
      • Current CloudSearch Plugin Doesn’t Work in the EU Region

What We Will Cover

@ngineered

3 of 20

Why Use Docker?

Very lightweight compared to traditional VM’s

Docker allows you to package the same configuration in:

  • Dev/Test
  • Stage
  • Production

When you need to repeatedly ship and deploy to lots of systems its reliable, as it allows you to group:

  • Configuration
  • Code (themes,plugins,core)
  • Data

You know it’s going to run when it comes to going live!

@ngineered

4 of 20

Docker on AWS

Parts Relevant to WordPress

  • Three CoreOS Servers
    • In a Private Subnet
    • Behind an ELB
    • In an AutoScale Group
  • Shared File System
  • MySQL on RDS
    • MultiAZ Deployment
  • S3 Offload
  • SES mail SMTP Gateway

@ngineered

5 of 20

Docker on AWS

@ngineered

6 of 20

The Container

https://registry.hub.docker.com/u/richarvey/nginx-php-fpm/

What’s included in the container:

  • Standard configuration and install of the latest Nginx
  • Standard configuration of PHP FPM
  • Git clone capabilities
  • Allows you to pull specific branches of your code at start time

+

+

@ngineered

7 of 20

Version Control

https://registry.hub.docker.com/u/richarvey/nginx-php-fpm/

The Container can pull code from git.

This allows you to ‘easily’ work on multiple features and/or fixes at the same time and test them in your container.

The container code also features a pull and push command to keep it in sync with a git repository.

@ngineered

8 of 20

Putting It All Together

https://registry.hub.docker.com/u/richarvey/nginx-php-fpm/

Running the container from the cli:

$ docker run --name worpress_prod -e 'TEMPLATE_NGINX_HTML=0' -e 'GIT_REPO=git@github.com:xyz/wordpress.git' -e ‘GIT_BRANCH=master’ -e 'GIT_NAME=Ric Harvey' -e 'GIT_EMAIL=ric@ngineered.co.uk' -v /opt/wpdeploy/:/root/.ssh -p 9090:80 -d richarvey/nginx-php-fpm:mainline

90dc407d7b35acd8753023819cfaf03dfe247a544d2786922758ca8bb03ee1d2

$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

90dc407d7b35 richarvey/nginx-php-fpm:mainline "/bin/bash /start.sh 11 seconds ago Up 11 seconds 443/tcp, 0.0.0.0:9090->80/tcp wordpress_prod

@ngineered

9 of 20

WordPress + Cloud Services = Awesome Scale

@ngineered

10 of 20

Offloading Key Services

Why?

  • Splitting your services gives you the ability to scale only the parts of the site that is slow
    • Less wastage of service resource
    • More cost efficient
  • An individual slow performing service doesn’t slow all services
    • Less user frustration
  • You can gracefully fail individual services (such as comments or search)

@ngineered

11 of 20

Amazon S3 and CloudFront Plugin

Description:

Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.

Active Installs: 10,000+

Download:

https://wordpress.org/plugins/amazon-s3-and-cloudfront/

You’ll also need:

https://wordpress.org/plugins/amazon-web-services/

(PHP Libs for AWS)

@ngineered

12 of 20

WP Super Cache Plugin

Description:

A very fast caching engine for WordPress that produces static html files.

Active Installs: 1+ million

Download:

https://wordpress.org/plugins/wp-super-cache/

@ngineered

13 of 20

Disqus Plugin

Description:

The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.

Active Installs: 200,000+

Download:

https://wordpress.org/plugins/disqus-comment-system/

@ngineered

14 of 20

Google Plugin

Description:

This plugin gives a very simple way to integrate Google Search into your WordPress site.

Active Installs: 3,000+

Download:

https://wordpress.org/plugins/wp-google-search/

@ngineered

15 of 20

WP SES Plugin

Description:

WP-SES redirects all outgoing WordPress emails through Amazon Simple Email Service (SES) for maximum email deliverability.

Active Installs: 2,000+

Download:

https://wordpress.org/plugins/wp-ses/

@ngineered

16 of 20

HyperDB Plugin

Description:

HyperDB is an advanced database class that supports replication, failover, load balancing, and partitioning.

Active Installs: Less than 10

Download:

https://wordpress.org/plugins/hyperdb/

@ngineered

17 of 20

RDS

Benefits

  • MultiAZ
    • data in multiple places
  • Automatic fail over
  • Automated backups
    • configurable
  • Automated upgrades
    • configurable

Read Slaves

  • Reduce pressure on your master server
    • offloading read requests
  • Speed up lookup times
    • using multiple read slaves
  • Free the master MySQL server up for writes

MySQL as a Service

@ngineered

18 of 20

Pull/Push Changes

https://registry.hub.docker.com/u/richarvey/nginx-php-fpm/

Push changes to Git:

$ docker exec -t -i wordpress_prod /usr/bin/push

Update the other running containers:

$ docker exec -t -i wordpress_prod /usr/bin/pull

@ngineered

19 of 20

Next Steps

http://kubernetes.io/

Schedulers for docker:

  • Cluster management tools like Kubernetes.
  • Allows you to easily manage a ‘Pod’ of WordPress Containers
  • Supports auto healing if a container/host fails

Service Discovery:

  • Use etcd for passing config/environmental variables to the container

@ngineered

20 of 20

@ngineered