Gearman, Supervisor and PHP - Job Management with Sanity!

Download Gearman, Supervisor and PHP - Job Management with Sanity!

Post on 15-Jan-2015

8.888 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

my talk in the phpXperts seminar 2011, Dhaka.

TRANSCRIPT

<ul><li> 1. Supervisor, Gearman and PHP - Jobmanagement with sanity!ABU ASHRAF MASNUN</li></ul> <p> 2. What is it all about? PHP GearmanSupervisor Job Management 3. Lets get REAL! Deploy Ninja A case studyPROPOSED FEATURES Deployment Solution (SVN to s/FTP) Trigger URL Web Hooks Deploy Now Deploy the latest right now Full Deploy Upload the entire repo again 4. How to train our Ninja?What did we have to do?REQUIREMENTS Tasks Involved: Fetch the repo Upload to the server Instant processing Process separation for the three deploymenttypes 5. And cometh the tragedy!The day my life sucked !^@# ARCHITECTURAL CHALLENGES Instant processing requires Daemons PHP was not built for long running processes! Premature termination &amp; Zombie processes. Monitoring the processes. Restarting the processes when terminated. 6. Gearman, the super hero!He came and saved my a$$ GEARMAN FEATURES Distributed workload management Client Worker Architecture Multiple workers Multi-lingual workers 7. Gearman: How it works? Understanding Gearman 8. Gearman: Installation Are you ready? QR CodeInstall Gearman:sudo apt-get install gearmanInstall Libgearman:sudo apt-get install libgearman-devInstall the PHP Extension:sudo pecl install channel://pecl.php.net/gearman-0.8.0 9. Gearman: Daemonizing!Starting Gearman QR CodeRunning GearmanDaemon:sudo gearman d u rootDebugging Gearman (Verbose mode) :sudo gearman d -vvv u root 10. QR CodeGearman: Workers PHP Worker 11. QR CodeGearman: Workers Breaking it down! 12. QR CodeGearman: Workers Breaking it down! 13. QR CodeGearman: Clients Requesting a job! 14. Gearman: Alternatives! Who else is there? RabbitMQ ZeroMQ Apache MQ Dropr Microsoft MQ 15. Whew! Almost done! Life is getting better CHALLENGES STATUS Instant processing requires Daemons PHP was not built for long running processes! Premature termination &amp; Zombie processes. Monitoring the processes. Restarting the processes when terminated. 16. Meet Supervisor! Here comes the tough guy! SUPERVISOR FEATURES Simple &amp; Centralized Efficient &amp; Extensible Compatible &amp; ProvenIt monitors your processes and restarts asinstructed! 17. Supervisor: Installation!Lets go! QR Codesudo apt-get install python-setuptools sudo easy_install supervisor 18. Supervisor: Getting Started! Config, debug and run!QR Codesudo echo_supervisord_conf &gt;/etc/supervisord.confsudo supervisord -nsudo supervisord 19. Hurray! Were done! Life is so good :D CHALLENGES STATUS Instant processing requires Daemons PHP was not built for long running processes! Premature termination &amp; Zombie processes. Monitoring the processes. Restarting the processes when terminated. 20. Whats your Story? You can do it too!USE CASES Image Processing? Cache Regeneration? Mass emails? 21. That was Simple! Eh?Got anything to ask? 22. The Leevian! Who am I? ABU ASHRAF MASNUNSoftware Engineer @ Leeviohttp://masnun.commasnun@leevio.com </p>