scale your php application with elastic beanstalk - cloudparty genova
DESCRIPTION
Scale your PHP application with AWS Elastic Beanstalk - Genova CloudParty 2014TRANSCRIPT
![Page 1: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/1.jpg)
Scale out our PHP application withElasticBeanstalk
![Page 2: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/2.jpg)
About meCofounder 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 PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/3.jpg)
ElasticBeanstalkScale your app workers and web apps
Queue DaemonsLoad balanced web applications
Mainly for Service Oriented Architecture
![Page 4: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/4.jpg)
Autoscaling applied to web applications
![Page 5: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/5.jpg)
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 6: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/6.jpg)
Run different environment per app
Typically you run: Production, Testing, Development
![Page 7: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/7.jpg)
Different app versions per environment
Easy distributed app deploy/rollback and testing/production application management
![Page 8: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/8.jpg)
Different configuration per environment
Upgrade your environment and switch your production without downtime
![Page 9: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/9.jpg)
Production Env Swap
![Page 10: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/10.jpg)
My production environment
![Page 11: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/11.jpg)
Add a new environment
![Page 12: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/12.jpg)
Swap production environment
ElasticBeanstalk swap env URLs in order to simplify the upgrade
![Page 13: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/13.jpg)
Destroy your old environment
COST-SAVING!it is easier create and destroy environments than upgrade them
![Page 14: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/14.jpg)
Environment Management
![Page 15: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/15.jpg)
Your scaling policies
![Page 16: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/16.jpg)
Scaling made easy
![Page 17: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/17.jpg)
Application variablesAll environment variables are ported to your application in $_SERVER
You can pass everything like: Memcached and Mysql configurations etc.
![Page 18: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/18.jpg)
Use Composer for DependenciesElasticBeanstalk uses composer in order to prepare your applicationUse composer hooks in order to connect all env variables to your app
configuration
![Page 19: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/19.jpg)
Composer hooks{ /** other composer configs **/ "scripts": { "post‐update‐cmd": [ "Corley\\Deploy\\Magento::updateConf" ], "post‐install‐cmd": [ "Corley\\Deploy\\Magento::updateConf" ] },}
![Page 20: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/20.jpg)
<?phpnamespace Corley\Deploy;
use Composer\Script\Event;
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 } }}
![Page 21: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/21.jpg)
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 22: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/22.jpg)
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 23: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/23.jpg)
Monitor your environment
You can monitor many metrics with CloudWatchUDP/IP CloudWatch agent on local machine: https://github.com/wdalmut/cloudwatch-agent
![Page 24: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/24.jpg)
What we are missing?
Logs!
![Page 25: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/25.jpg)
Grab all active instances logs
![Page 26: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/26.jpg)
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 27: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/27.jpg)
Collecting all application logsAWS ELB can store all logs into a S3 bucket using a scheduled system
COST-SAVING! we don't need to propagate logs via "rsyslog"
![Page 28: Scale your PHP application with Elastic Beanstalk - CloudParty Genova](https://reader035.vdocument.in/reader035/viewer/2022062406/55923ecc1a28ab153f8b461f/html5/thumbnails/28.jpg)
Thanks for listening
Any question?