SlideShare a Scribd company logo
Running and
scaling
Running and Scaling Magento on AWS
& aoepeople!
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
PuTTY
$ ssh ubuntu@<publicDnsName>
$ sudo apt-get update
$ sudo apt-get install lamp-server^ 
php5-mcrypt php5-curl php5-gd php5-intl php5-xsl 
mysql-server-5.6 redis-server 
varnish
$ sudo php5enmod mcrypt
$ sudo a2enmod rewrite
^C
exit
$ rsync –av . ubuntu@<publicDnsName>:/var/www/html
Apache
PHP
MySQL
Redis
Varnish
EC2 Instance
DNS
Running and Scaling Magento on AWS
reserved
instance…
Running and Scaling Magento on AWS
Automation
Security
Scalability
Elasticity
Resilience
Running and Scaling Magento on AWS
Database
Servers
Cache
Load Balancer Firewall
DNS
Network
Streams
Queues Monitoring Logging Pubsub
Deployment Storage CDN EmailF
S
low
ity
some of those services are
but some aren’t!
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Region: eu-west-1 (Ireland)
Availability Zone
eu-west-1a
Availability Zone
eu-west-1c
Availability Zone
eu-west-1b
Running and Scaling Magento on AWS
Region: eu-west-1 (Ireland)
VPC
Availability Zone
eu-west-1a
Availability Zone
eu-west-1c
Availability Zone
eu-west-1b
Public Subnet Public Subnet Public Subnet
Private Subnet Private Subnet Private Subnet
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Auto Scaling group
Auto Scaling group
Elastic Load
Balancer
Auto Scaling group Auto Scaling group
Elastic Load
Balancer
Public subnets
Private subnets
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Auto Scaling group
Auto Scaling group
Elastic Load
Balancer
Auto Scaling group Auto Scaling group
Elastic Load
Balancer
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
What can I use for “media/” when
deploying Magento to multiple
servers?
“I’ll just
use rsync
on cron”
Are you
on AWS?
Is EFS
out yet?
AWS EFS
Are you willing
to deal with
NFS/
GlusterFS?
NFS/
GlusterFS
Is this only
about
product
images?
only a few
files?
Magento’s
DB + get.php
Aoe_AmazonCDN
(S3 + CloudFront)
S3FS +
CloudFront
nope! Seriously: no!
no
yes
yesnoyes
no
yes
no
yes
no
and/or are you willing to update
all other module’s code to not
access the file system directly but
use a different API instead?
…or other modules that
abstract from the local
filesystem. “Flysystem” is a
great foundation for that
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Auto Scaling group
Auto Scaling group
Elastic Load
Balancer
Auto Scaling grou
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
/i(m)ˈmyo͞ odəb(ə)l/
adjective
unchanging over time or unable to be changed.
“disposable”
“ephemeral”
Pet
Cattle
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
not disposable disposable
disposable
not disposable
disposable
Static Resources BuildVPC Build
Private subnets
Public subnets
ElastiCache (Redis)
with replication groups
for cache and sessions
RDS (multi-az) with
DB subnet group
Bastion
server
s3: media
storage*
Route 53: DNS
configuration
CloudFront
distribution
SSL
Certificates
Security group for Varnish servers
Security group for Magento servers
Security group for Load Balancer
Static Resources
Build
Auto Scaling group
Auto Scaling group
Elastic Load
Balancer
Auto-
Scaling
Group
Launch
Configurati
on
Scaling
Policy
Auto Scaling group Auto Scaling group
Urls
Database
Settings
Payment Provider
Configuration Feature
Flags…
Everything that’s
different between two
environments
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
Running and Scaling Magento on AWS
“Chef vs. Puppet?”
http://fbrnc.net/blog/2015/11/
how-to-provision-an-ec2-instance
“…Ansible!”
“BASH!”
Keep it simple…!
✔ ✔ ✔
aoepeople/stackformation
command-line tool
(Symfony console, uses
AWS SDK for PHP)
integrates nicely into
your CI (Jenknis,…)
Have fun
filling out
47 form
fields! :)
blueprints:
- stackname: 'magento-{env:BUILD}'
template: 'magento.template'
stackPolicy: 'policy.json'
OnFailure: 'DO_NOTHING'
parameters:
Build: '{env:BUILD}'
KeyPair: '{var:KeyPair}'
VPC: '{resource:setupstack:VPC}'
Subnet: '{resource:setupstack:Subnet}'
InstanceSg: '{resource:setupstack:InstanceSg}'
InstanceProfile: '{output:setupstack:InstanceProfile}'
BootAmi: 'ami-06116566'
tags:
Environment: 'prod'
Build: '{env:BUILD}'
enforce
“immutability” by
denying updates!
aoepeople/cfn-vpc
aoepeople/cfn-lambdahelper
aoepeople/cfn-amibaker
via composer
so we can
integrate this into
our CI pipeline…
•
Running and Scaling Magento on AWS
aoepeople/awsinspector
command-line tool
(Symfony console, uses
AWS SDK for PHP)
Domain models for PHP
$repository = new AwsInspectorModelElbRepository();
$dns = $repository->findElbsByTags([
'Environment' => 'deploy',
'Build' => 554,
'Type' => 'Frontend’
])->getFirst()->getDNSName();
> bin/awsinspector.php ec2:ssh -t Environment:prod –c Type –c Build
filter by tag
Please select an instance
[0] i-1033ed9b (Type: Frontend; Environment: prod; Build: 477)
[1] i-4ff36ec8 (Type: Backend; Environment: prod ; Build: 477)
[2] i-5ab4322b (Type: Worker; Environment: prod; Build: 477)
[3] i-705ad42f (Type: Worker; Environment: prod; Build: 476)
>
• will take jump hosts into
account (ProxyCommand)
• auto-detects your local
(encrypted) private keys
• multiplexed ssh connections
• run commands directly
with CloudFormation
and Lambda
Follow me on twitter!
My blog

More Related Content

Running and Scaling Magento on AWS