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.

Scale your PHP application with Elastic Beanstalk - CloudParty Genova

2,441 views

Published on

Scale your PHP application with AWS Elastic Beanstalk - Genova CloudParty 2014

Published in: Technology
  • Be the first to comment

Scale your PHP application with Elastic Beanstalk - CloudParty Genova

  1. 1. Scale out our PHP application with ElasticBeanstalk
  2. 2. About me Cofounder Cofounder Corley S.r.l. - @CorleyCloud UpCloo LTD - @UpCloo on Github on Twitter wdalmut walterdalmut - Internet Of Things! @ Turin [CFP] - 15 Nov - CloudComputing @ Turin [CFP ASAP] internetof.it www.cloudconf.it
  3. 3. ElasticBeanstalk Scale your app workers and web apps Queue Daemons Load balanced web applications Mainly for Service Oriented Architecture
  4. 4. Autoscaling applied to web applications
  5. 5. Scale apps is not simple How 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!)
  6. 6. Run different environment per app Typically you run: Production, Testing, Development
  7. 7. Different app versions per environment Easy distributed app deploy/rollback and testing/production application management
  8. 8. Different configuration per environment Upgrade your environment and switch your production without downtime
  9. 9. Production Env Swap
  10. 10. My production environment
  11. 11. Add a new environment
  12. 12. Swap production environment ElasticBeanstalk swap env URLs in order to simplify the upgrade
  13. 13. Destroy your old environment COST-SAVING! it is easier create and destroy environments than upgrade them
  14. 14. Environment Management
  15. 15. Your scaling policies
  16. 16. Scaling made easy
  17. 17. Application variables All environment variables are ported to your application in $_SERVER You can pass everything like: Memcached and Mysql configurations etc.
  18. 18. Use Composer for Dependencies ElasticBeanstalk uses composer in order to prepare your application Use composer hooks in order to connect all env variables to your app configuration
  19. 19. Composer hooks { /** other composer configs **/ "scripts": { "post‐update‐cmd": [ "CorleyDeployMagento::updateConf" ], "post‐install‐cmd": [ "CorleyDeployMagento::updateConf" ] }, }
  20. 20. <?php namespace CorleyDeploy; use ComposerScriptEvent; class Magento { public static function updateConf(Event $event) { if (array_key_exists("OVERWRITE_CONF", $_SERVER)) { // Update your config file when $_SERVER contains "OVERWRITE_CONF" variable } } }
  21. 21. 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
  22. 22. 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_leader_only: true All configuration files are just simple YAML files
  23. 23. Monitor your environment You can monitor many metrics with CloudWatch UDP/IP CloudWatch agent on local machine: https://github.com/wdalmut/cloudwatch-agent
  24. 24. What we are missing? Logs!
  25. 25. Grab all active instances logs
  26. 26. 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
  27. 27. Collecting all application logs AWS ELB can store all logs into a S3 bucket using a scheduled system COST-SAVING! we don't need to propagate logs via "rsyslog"
  28. 28. Thanks for listening Any question?

×