(web302) best practices for running wordpress on aws | aws re:invent 2014

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

Upload: amazon-web-services

Post on 24-Jun-2015

2.890 views

Category:

Technology


11 download

DESCRIPTION

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.

TRANSCRIPT

November 12, 2014 | Las Vegas, NV

Andreas Chatzakis, Solutions Architect, AWS

Chris Pitchford, Lead Platform Owner, News UK

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

WordPress server

(Apache, MySQL)

Elastic IP

www.example.com

Amazon Route 53

DNS service

WordPress server

image (AMI)

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/

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

Level 4 - Lando 4301A

S3 bucket for

static assets

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

Watch 2013 re:Invent session recording:

ARC309 Dynamic Content Acceleration CloudFront

Amazon

Route 53

EC2 instance(s)

S3 bucket

Static content

Dynamic content

wp-content/*

wp-includes/*

wp-admin/*

wp-login.php

Default(*)

CloudFront

distribution

Route 53 S3 bucket

Static content

wp-content/*

wp-includes/*

CloudFront

distribution

m1.example.com

m2.example.com

m3.example.com

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

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

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

CloudFront

seafood.jpgseafood-300x225.jpg

seafood-150x150.jpg

$_SERVER['HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER']

$_SERVER['HTTP_CLOUDFRONT_IS_TABLET_VIEWER']

$_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER']

CloudFront

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

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

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

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

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

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

$_SERVER["RDS_DB_NAME"]

$_SERVER["RDS_USERNAME"]

$_SERVER["RDS_PASSWORD"]

$_SERVER["RDS_HOSTNAME"]

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

November 12, 2014 | Las Vegas, NV

Chris Pitchford, Lead Platform Owner, News UK

• Base application containing all plugins

– Let website pick from menu

• Plugins adhere to WordPress VIP standards

– Automated testing and code review

• Config in DB, EC2 User Data or CloudFormation

– No hard coded values

• AWS credentials: IAM roles and session tokens

– No IAM user credentials

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

www.mysite.com/mywordpress/

Pushing to open source. Native support for

Apache 2.4 and Varnish 4 (and Nginx maybe)

http://bit.ly/awsevals