(WEB302) Best Practices for Running WordPress on AWS | AWS re:Invent 2014
-
Upload
amazon-web-services -
Category
Technology
-
view
2.890 -
download
11
description
Transcript of (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
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
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
$_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
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
• 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