Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Running and Scaling Magento on AWS

Magento Imagine 2016

Running and Scaling Magento on AWS

  1. 1. Running and scaling
  2. 2. & aoepeople!
  3. 3. 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
  4. 4. Apache PHP MySQL Redis Varnish EC2 Instance DNS
  5. 5. reserved instance…
  6. 6. Automation Security Scalability Elasticity Resilience
  7. 7. Database Servers Cache Load Balancer Firewall DNS Network Streams Queues Monitoring Logging Pubsub Deployment Storage CDN EmailF S low ity
  8. 8. some of those services are but some aren’t!
  9. 9. Region: eu-west-1 (Ireland) Availability Zone eu-west-1a Availability Zone eu-west-1c Availability Zone eu-west-1b
  10. 10. 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
  11. 11. Auto Scaling group Auto Scaling group Elastic Load Balancer Auto Scaling group Auto Scaling group Elastic Load Balancer Public subnets Private subnets
  12. 12. Auto Scaling group Auto Scaling group Elastic Load Balancer Auto Scaling group Auto Scaling group Elastic Load Balancer
  13. 13. 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
  14. 14. Auto Scaling group Auto Scaling group Elastic Load Balancer Auto Scaling grou
  15. 15. /i(m)ˈmyo͞ odəb(ə)l/ adjective unchanging over time or unable to be changed. “disposable” “ephemeral”
  16. 16. Pet Cattle
  17. 17. not disposable disposable
  18. 18. disposable not disposable disposable
  19. 19. Static Resources BuildVPC Build
  20. 20. 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
  21. 21. Build Auto Scaling group Auto Scaling group Elastic Load Balancer Auto- Scaling Group Launch Configurati on Scaling Policy Auto Scaling group Auto Scaling group
  22. 22. Urls Database Settings Payment Provider Configuration Feature Flags… Everything that’s different between two environments
  23. 23. “Chef vs. Puppet?” http://fbrnc.net/blog/2015/11/ how-to-provision-an-ec2-instance “…Ansible!” “BASH!”
  24. 24. Keep it simple…!
  25. 25. ✔ ✔ ✔
  26. 26. aoepeople/stackformation command-line tool (Symfony console, uses AWS SDK for PHP) integrates nicely into your CI (Jenknis,…)
  27. 27. Have fun filling out 47 form fields! :)
  28. 28. 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!
  29. 29. aoepeople/cfn-vpc aoepeople/cfn-lambdahelper aoepeople/cfn-amibaker via composer
  30. 30. so we can integrate this into our CI pipeline…
  31. 31.
  32. 32. aoepeople/awsinspector command-line tool (Symfony console, uses AWS SDK for PHP) Domain models for PHP
  33. 33. $repository = new AwsInspectorModelElbRepository(); $dns = $repository->findElbsByTags([ 'Environment' => 'deploy', 'Build' => 554, 'Type' => 'Frontend’ ])->getFirst()->getDNSName();
  34. 34. > 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
  35. 35. with CloudFormation and Lambda
  36. 36. Follow me on twitter! My blog

×