Top Banner
November 12, 2014 | Las Vegas, NV Andreas Chatzakis, Solutions Architect, AWS Chris Pitchford, Lead Platform Owner, News UK
55

(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Jun 24, 2015

Download

Technology

WordPress is an open-source blogging tool and content management system (CMS) that can power anything from personal blogs to high traffic websites. This session covers best practices for deploying scalable Wordpress-powered websites on AWS. Starting from one-click single-instance installations from the AWS Marketplace, we move on to Wordpress implementation details that help you make the most of AWS elasticity. We provide a blueprint architecture for high availability (Elastic Load Balancing, Auto Scaling, Amazon RDS multi-AZ). You learn how to use Amazon S3 to create a stateless web tier, how to improve performance with Amazon ElastiCache and Amazon CloudFront, how to manage your application lifecycle with AWS Elastic Beanstalk, and more.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

November 12, 2014 | Las Vegas, NV

Andreas Chatzakis, Solutions Architect, AWS

Chris Pitchford, Lead Platform Owner, News UK

Page 2: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 3: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 4: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 5: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

DIY or AWS Marketplace

$ sudo yum update -y$ sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"$ sudo yum install -y php-mysql$ sudo service httpd startStarting httpd: [ OK ]$ sudo chkconfig httpd on

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

Page 6: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

WordPress server

(Apache, MySQL)

Elastic IP

www.example.com

Amazon Route 53

DNS service

WordPress server

image (AMI)

Page 7: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 8: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 9: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

WordPress Server

(Apache, MySQL)

Elastic IP

WordPress server

image (AMI)

www.example.com

Amazon Route 53

DNS service

EBS volumeEBS snapshot

/var/www/html/wp-config.php

/var/www/html/wp-content/

/var/lib/mysql/

Page 10: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 11: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

WEB401 - Optimizing Your Web Server on AWS Thursday, Nov 13, 11:00 AM - 11:45 AM

Level 4 - Lando 4301A

Page 12: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 13: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 14: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

S3 bucket for

static assets

http://<bucketname>.s3.amazonaws.com/wp-content/uploads/2014/10/aws.jpg

Page 15: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Watch 2013 re:Invent session recording:

ARC309 Dynamic Content Acceleration CloudFront

Page 16: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Amazon

Route 53

EC2 instance(s)

S3 bucket

Static content

Dynamic content

wp-content/*

wp-includes/*

wp-admin/*

wp-login.php

Default(*)

CloudFront

distribution

Page 17: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Route 53 S3 bucket

Static content

wp-content/*

wp-includes/*

CloudFront

distribution

m1.example.com

m2.example.com

m3.example.com

Page 18: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

CloudFront

Static Dynamic (admin) Dynamic (front end)

Pathswp-content/*wp-includes/*

wp-admin/*wp-login.php

default (*)

Protocols HTTP and HTTPS Redirect to HTTPS HTTP and HTTPSHTTP methods GET, HEAD ALL ALLQuery strings YES (invalidation) YES YES

Cookies

NONE ALL wordpress_*wp-settings-* comment_*

Headers

NONE ALL CloudFront-Forwarded-ProtoCloudfront-Is-Desktop-ViewerCloudfront-Is-Mobile-ViewerCloudfront-Is-Tablet-Viewer

/wp-content/themes/my-theme/style.css?version=3410bf

Page 19: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

CloudFront

Static Dynamic (admin) Dynamic (front end)

Pathswp-content/*wp-includes/*

wp-admin/*wp-login.php

default (*)

Protocols HTTP and HTTPS Redirect to HTTPS HTTP and HTTPSHTTP methods GET, HEAD ALL ALLQuery strings YES (invalidation) YES YES

Cookies

NONE ALL wordpress_*wp-settings-* comment_*

Headers

NONE ALL CloudFront-Forwarded-ProtoCloudfront-Is-Desktop-ViewerCloudfront-Is-Mobile-ViewerCloudfront-Is-Tablet-Viewer

Page 20: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

CloudFront

Static Dynamic (admin) Dynamic (front end)

Pathswp-content/*wp-includes/*

wp-admin/*wp-login.php

default (*)

Protocols HTTP and HTTPS Redirect to HTTPS HTTP and HTTPSHTTP methods GET, HEAD ALL ALLQuery strings YES (invalidation) YES YES

Cookies

NONE ALL wordpress_*wp-settings-* comment_*

Headers

NONE ALL CloudFront-Forwarded-ProtoCloudfront-Is-Desktop-ViewerCloudfront-Is-Mobile-ViewerCloudfront-Is-Tablet-Viewer

Page 21: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

CloudFront

Page 22: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

seafood.jpgseafood-300x225.jpg

seafood-150x150.jpg

Page 23: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

$_SERVER['HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER']

$_SERVER['HTTP_CLOUDFRONT_IS_TABLET_VIEWER']

$_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER']

CloudFront

Page 24: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 25: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

WordPress web

server

1. If data in cache,

return result

2. If not in cache,

read from DBRDS database

Amazon ElastiCache

3. And store

in cache

Page 26: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 27: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Availability Zone a

RDS DB

instance

ElastiCache

node 1

Availability Zone b

S3 bucket for

static assets

www.example.com

Amazon Route 53

DNS service

Elastic Load

Balancing

Web

serverWeb

server

Page 28: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 29: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Availability Zone a

RDS DB

instance

ElastiCache

node 1

Availability Zone b

S3 bucket for

static assets

www.example.com

Amazon Route 53

DNS service

Elastic Load

Balancing

Web

serverWeb

server

RDS DB

standby

ElastiCache

node 2

Page 30: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 31: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

CPU>60%

CloudWatch

Availability Zone a

RDS DB

instance

ElastiCache

Node 1

Availability Zone b

S3 bucket for

static assets

www.example.com

Amazon Route 53

DNS service

Elastic Load

Balancing

RDS DB

standby

ElastiCache

Node 2

Web

server

Web

server

Page 32: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Web

server

Web

server

Web

server

Web

server

Alarm Auto Scaling

Availability Zone a

RDS DB

instance

Availability Zone b

S3 bucket for

static assets

www.example.com

Amazon Route 53

DNS service

Elastic Load

Balancing

RDS DB

standby

ElastiCache

Node 1

ElastiCache

Node 2

Page 33: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 34: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Web

server

Web

server

Web

server

Web

server

Availability Zone a

RDS DB

instance

ElastiCache

node 1

Availability Zone b

S3 bucket for

static assets

www.example.com

Amazon Route 53

DNS service

Elastic Load

Balancing

RDS DB

standby

ElastiCache

node 2 RDS read

replicaRDS read

replica

Page 35: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 36: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 37: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

$_SERVER["RDS_DB_NAME"]

$_SERVER["RDS_USERNAME"]

$_SERVER["RDS_PASSWORD"]

$_SERVER["RDS_HOSTNAME"]

Page 38: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

DB

Ap

pE

LB

https://prod.elasticbeanstalk.com

DB

Ap

p

https://staging.elasticbeanstalk.com

v1

1. Install plugin

v2

2. Generate

new zip file

3. Deploy in

production4. Trigger DB updates

Page 39: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

November 12, 2014 | Las Vegas, NV

Chris Pitchford, Lead Platform Owner, News UK

Page 40: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 41: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 42: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 43: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 44: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 45: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

• Base application containing all plugins

– Let website pick from menu

• Plugins adhere to WordPress VIP standards

– Automated testing and code review

Page 46: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

• Config in DB, EC2 User Data or CloudFormation

– No hard coded values

• AWS credentials: IAM roles and session tokens

– No IAM user credentials

Page 47: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 48: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 49: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 50: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

www.site.com test-b.site.com cache.site.com

Page 51: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 52: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

www.mysite.com/mywordpress/

Page 53: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

Pushing to open source. Native support for

Apache 2.4 and Varnish 4 (and Nginx maybe)

Page 54: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
Page 55: (WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014

http://bit.ly/awsevals