+ All Categories
Home > Software > Scale your Magento app with Elastic Beanstalk

Scale your Magento app with Elastic Beanstalk

Date post: 30-Jun-2015
Category:
Upload: corley-srl
View: 865 times
Download: 5 times
Share this document with a friend
Description:
Scale your Magento Ecommerce with AWS Elastic Beanstalk - Mageday 2014 - With @kesonno @bitbull
38
Scale out your Magento application with ElasticBeanstalk
Transcript
Page 1: Scale your Magento app with Elastic Beanstalk

Scale out your Magento application withElasticBeanstalk

Page 2: Scale your Magento app with Elastic Beanstalk

About usCofounder & CTO -

on Github on Twitter

Bitbull S.r.l. @Bitbull_itbitbull-teamkesonno

Cofounder - Cofounder -

on Github on Twitter

Corley S.r.l. @CorleyCloudUpCloo LTD @UpCloo

wdalmutwalterdalmut

- Internet Of Things! @ Turin [CFP] - 15 Nov - CloudComputing @ Turin [CFP ASAP]

internetof.itwww.cloudconf.it

Page 3: Scale your Magento app with Elastic Beanstalk

ElasticBeanstalkScale your app workers and web apps

Queue DaemonsLoad balanced web applications

Mainly for Service Oriented Architecture

Page 4: Scale your Magento app with Elastic Beanstalk

Autoscaling applied to web applications

Page 5: Scale your Magento app with Elastic Beanstalk

Autoscaling in practice

Dynamically added and removed!

Machine to Machine

Closed-loop control system

Page 6: Scale your Magento app with Elastic Beanstalk

Scale apps is not simpleHow to handle dev/testing/production? (dynamic env)How to install/update softwares? (dynamic env)How to handle user sessions? (more than one node)How to handle/tail logs? (dynamic env)How to monitor all instances (dynamic env)And more... (all things are moving!)

Page 7: Scale your Magento app with Elastic Beanstalk

Run different environment per app

Typically you run: Production, Testing, Development

Page 8: Scale your Magento app with Elastic Beanstalk

How to deploy the app?ElasticBeanstalk updates app using Git on pushElasticBeanstalk updates app using a pre-packaged Zip file

ElasticBeankstalk offers also API

Git Push -> Jenkins Build ZIP package -> ElasticBeankstalk Deploy

Page 9: Scale your Magento app with Elastic Beanstalk

Different app versions per environment

Easy distributed app deploy/rollback and testing/production application management

Page 10: Scale your Magento app with Elastic Beanstalk

Different configuration per environment

Upgrade your environment and switch your production without downtime

Page 11: Scale your Magento app with Elastic Beanstalk

Production Env Swap

Page 12: Scale your Magento app with Elastic Beanstalk

My production environment

Page 13: Scale your Magento app with Elastic Beanstalk

Add a new environment

Page 14: Scale your Magento app with Elastic Beanstalk

Swap production environment

ElasticBeanstalk swap env URLs in order to simplify the upgrade

Page 15: Scale your Magento app with Elastic Beanstalk

Destroy your old environment

COST-SAVING!it is easier create and destroy environments than upgrade them

Page 16: Scale your Magento app with Elastic Beanstalk

Environment Management

Page 17: Scale your Magento app with Elastic Beanstalk

Control your ApplicationConfigurations

Page 18: Scale your Magento app with Elastic Beanstalk

Application variablesAll environment variables are ported to your application in $_SERVER

You can pass everything like: Memcached and Mysql configurations etc.

Page 19: Scale your Magento app with Elastic Beanstalk

Scaling made easy

Page 20: Scale your Magento app with Elastic Beanstalk

We need more customizations!Create a folder in your project root with name .ebextensions and

append your configuration files with extension .config

ElasticBeanstalk will use them during the application provisioning

Page 21: Scale your Magento app with Elastic Beanstalk

Cronjobs runs on the leader instance only.ebextensions/05_cron_jobs.config

container_commands:    01_magento_cron_job:    command: "cat .ebextensions/magento_cron_job.txt > /etc/cron.d/magento_cron_job && chmod 644 /etc/cron.d/magento_cron_job"    leader_only: true

All configuration files are just simple YAML files

Page 22: Scale your Magento app with Elastic Beanstalk

Monitor your environment

You can monitor many metrics with CloudWatchUDP/IP CloudWatch agent on local machine: https://github.com/wdalmut/cloudwatch-agent

Page 23: Scale your Magento app with Elastic Beanstalk

What we are missing?

Logs!

Page 24: Scale your Magento app with Elastic Beanstalk

Grab all active instances logs

Page 25: Scale your Magento app with Elastic Beanstalk

But my application logs?commands:    21_application_logs:        command: echo "/var/app/current/var/log/*.log" > myapp.conf        cwd: /opt/elasticbeanstalk/tasks/bundlelogs.d    22_application_logs:        command: echo "/var/app/current/var/log/*.log" > myapp.conf        cwd: /opt/elasticbeanstalk/tasks/systemtaillogs.d    23_application_logs:        command: echo "/var/app/current/var/log/*.log" > myapp.conf        cwd: /opt/elasticbeanstalk/tasks/taillogs.d    24_application_logs:        command: echo "/var/app/current/var/log/*.log" > myapp.conf        cwd: /opt/elasticbeanstalk/tasks/publishlogs.d

.ebextensions/06_prepare_logs.config

Page 26: Scale your Magento app with Elastic Beanstalk

The Magento side

Page 27: Scale your Magento app with Elastic Beanstalk

Use Composer for dependenciesElasticBeanstalk uses Composer in order to prepare your application

So, we can use composer hooks in order to connect all env variables toour Magento configuration

http://github.com/magento-hackathon/magento-composer-installer

Page 28: Scale your Magento app with Elastic Beanstalk

Composer hooks{    /** other composer configs **/    "scripts": {        "post‐update‐cmd": [            "Corley\\Deploy\\Magento::localConf"        ],        "post‐install‐cmd": [            "Corley\\Deploy\\Magento::localConf"        ]    },}

Page 29: Scale your Magento app with Elastic Beanstalk

<?phpnamespace Corley\Deploy;

use Composer\Script\Event;

class Magento{    public static function localConf(Event $event)    {        // Generate a local.xml based on environment variables    }}

Page 30: Scale your Magento app with Elastic Beanstalk

The golden rule:

The filesystem is not reliable

Page 31: Scale your Magento app with Elastic Beanstalk

Keep media in a shared locationok but, what could we use?

Page 32: Scale your Magento app with Elastic Beanstalk

NFS?is a single point of failureis not at web scale

Page 33: Scale your Magento app with Elastic Beanstalk

Amazon S3?does not work out-of-the-boxmaybe in future...

Page 34: Scale your Magento app with Elastic Beanstalk

Database?

Page 35: Scale your Magento app with Elastic Beanstalk

Why not?work out-of-the-box (and is dead simple to configure)

read access to db only once for each instance......may be reduced to only one using a CDN (CloudFront)

Page 36: Scale your Magento app with Elastic Beanstalk

Cache and sessionsAll cache backend and session handlers except "File" are fineBest options are Redis and Memcached (both available via AmazonElastiCache)

Page 37: Scale your Magento app with Elastic Beanstalk

TO BE DONEsitemap.xmlExchange data for third-party integration (ERP, CRM etc.)Integration with services (eg. bank gateway) that require IPs whitelist

Use a proxyIP reservation

Store media on Amazon S3Use DynamoDB session handler

Page 38: Scale your Magento app with Elastic Beanstalk

Thanks for listening

Any question?


Recommended