Top Banner
Running and scaling
66

Running and Scaling Magento on AWS

Jan 08, 2017

Download

Technology

AOE
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: Running and Scaling Magento on AWS

Running and scaling

Page 2: Running and Scaling Magento on AWS
Page 3: Running and Scaling Magento on AWS

& aoepeople!

Page 4: Running and Scaling Magento on AWS
Page 5: Running and Scaling Magento on AWS
Page 6: Running and Scaling Magento on AWS
Page 7: 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

Page 8: Running and Scaling Magento on AWS

Apache

PHP

MySQL

Redis

Varnish

EC2 Instance

DNS

Page 9: Running and Scaling Magento on AWS
Page 10: Running and Scaling Magento on AWS

reserved instance…

Page 11: Running and Scaling Magento on AWS
Page 12: Running and Scaling Magento on AWS

Automation

Security

Scalability

Elasticity

Resilience

Page 13: Running and Scaling Magento on AWS
Page 14: Running and Scaling Magento on AWS

Database

Servers

Cache

Load Balancer Firewall

DNS

Network

Streams

Queues Monitoring Logging Pubsub

Deployment Storage CDN Email WAF

VCS

Workflow

Identity

Page 15: Running and Scaling Magento on AWS

some of those services are

but some aren’t!

Page 16: Running and Scaling Magento on AWS
Page 17: Running and Scaling Magento on AWS
Page 18: 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

Page 19: Running and Scaling Magento on AWS
Page 20: 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

Page 21: Running and Scaling Magento on AWS
Page 22: Running and Scaling Magento on AWS
Page 23: 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

Page 24: Running and Scaling Magento on AWS
Page 25: Running and Scaling Magento on AWS
Page 26: Running and Scaling Magento on AWS

Auto Scaling group

Auto Scaling group

Elastic Load

Balancer

Auto Scaling group Auto Scaling group

Elastic Load

Balancer

Page 27: Running and Scaling Magento on AWS
Page 28: Running and Scaling Magento on AWS
Page 29: 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

yes no yes

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

Page 30: Running and Scaling Magento on AWS
Page 31: Running and Scaling Magento on AWS
Page 32: Running and Scaling Magento on AWS
Page 33: Running and Scaling Magento on AWS
Page 34: Running and Scaling Magento on AWS

Auto Scaling group

Auto Scaling group

Elastic Load

Balancer

Auto Scaling group Auto Scaling group

Elastic Load

Balancer

Page 35: Running and Scaling Magento on AWS
Page 36: Running and Scaling Magento on AWS
Page 37: Running and Scaling Magento on AWS

/i(m)ˈmyo͞odəb(ə)l/

adjective

unchanging over time or unable to be changed.

“disposable” “ephemeral”

Page 38: Running and Scaling Magento on AWS

Pet Cattle

Page 39: Running and Scaling Magento on AWS
Page 40: Running and Scaling Magento on AWS
Page 41: Running and Scaling Magento on AWS

not disposable disposable

Page 42: Running and Scaling Magento on AWS

disposable

not disposable

disposable

Page 43: Running and Scaling Magento on AWS

Static Resources Build VPC Build

Page 44: Running and Scaling Magento on AWS

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

Page 45: Running and Scaling Magento on AWS

Build

Auto Scaling group

Auto Scaling group

Elastic Load

Balancer

Auto-

Scaling

Group

Launch

Configurati

on

Scaling

Policy

Auto Scaling group Auto Scaling group

Page 46: Running and Scaling Magento on AWS

Urls

Database Settings

Payment Provider Configuration Feature

Flags…

Everything that’s different between two

environments

Page 47: Running and Scaling Magento on AWS
Page 48: Running and Scaling Magento on AWS
Page 49: Running and Scaling Magento on AWS
Page 50: Running and Scaling Magento on AWS
Page 51: Running and Scaling Magento on AWS
Page 53: Running and Scaling Magento on AWS

Keep it simple…!

Page 54: Running and Scaling Magento on AWS

✔ ✔ ✔

Page 55: Running and Scaling Magento on AWS

aoepeople/stackformation

command-line tool (Symfony console, uses

AWS SDK for PHP)

integrates nicely into your CI (Jenknis,…)

Page 56: Running and Scaling Magento on AWS

Have fun filling out 47 form fields! :)

Page 57: Running and Scaling Magento on AWS

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!

Page 58: Running and Scaling Magento on AWS

aoepeople/cfn-vpc

aoepeople/cfn-lambdahelper

aoepeople/cfn-amibaker

via composer

Page 59: Running and Scaling Magento on AWS

so we can integrate this into our CI pipeline…

Page 60: Running and Scaling Magento on AWS

Page 61: Running and Scaling Magento on AWS
Page 62: Running and Scaling Magento on AWS

aoepeople/awsinspector

command-line tool (Symfony console, uses

AWS SDK for PHP)

Domain models for PHP

Page 63: Running and Scaling Magento on AWS

$repository = new \AwsInspector\Model\Elb\Repository(); $dns = $repository->findElbsByTags([ 'Environment' => 'deploy', 'Build' => 554, 'Type' => 'Frontend’ ])->getFirst()->getDNSName();

Page 64: Running and Scaling Magento on AWS

> 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

Page 65: Running and Scaling Magento on AWS

with CloudFormation and Lambda

Page 66: Running and Scaling Magento on AWS

Follow me on twitter!

My blog