Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP-Queue with Windows Azure

PHP-Queue with Windows Azure

Demo app for Windows Azure Service Bus Queue backend.

Part of my presentation at The Singapore Xmas Azure Workshop on 20 Dec 2012 (https://www.facebook.com/events/382258025194568/).

Sample code: https://github.com/miccheng/PHP-Queue-Windows-Azure-Queue-Demo

Michael Cheng

December 20, 2012
Tweet

More Decks by Michael Cheng

Other Decks in Programming

Transcript

  1. Example Web App Messaging Queue Worker Worker Worker Windows Azure

    Service Bus, Amazon SQS, IronMQ, Beanstalkd, Gearman, RabbitMQ, MSMQ 4 Thursday, 20 December, 12
  2. Why PHP-Queue? • Its not easy implementing a messaging queue.

    • Which backend? Hosted/Self-host? • Learning curve - protocols, libraries. • Not responsive to changing use cases. • Vendor locked-in. 5 Thursday, 20 December, 12
  3. Benefits of PHP-Queue • Backend agnostic. • Flexible job queue

    implementation. • 1 queue 1 type of jobs. • 1 queue many types of jobs. • Independent workers. Chainable. • Powerful. • REST server, CLI, daemons. 6 Thursday, 20 December, 12
  4. • PHP is a first class citizen. • Documentation is

    very decent (lotsa examples). •Free 90 days trial! • Windows Azure PHP SDK is Composer compatible! • Continuous Deployment with Git 7 Thursday, 20 December, 12
  5. • Web Sites • Virtual Machines • Mobile Services •

    Cloud Services • Big Data • Media 8 Thursday, 20 December, 12
  6. Windows Azure Service Bus • Service Bus is messaging infrastructure

    that sits between applications allowing them to exchange messages in a loosely coupled way for improved scale and resiliency. Service Bus is managed and operated by Microsoft with a 99.9% monthly SLA. 9 Thursday, 20 December, 12
  7. Components • Web Site • REST interface, Photo Gallery •

    Service Bus Queue • Messaging Queue • Blob Service • Photos • Virtual Machine • Photo Workers 11 Thursday, 20 December, 12
  8. Simple Queue • REST interface • curl -XPOST http://phpqueuedemo.azurewebsites.net/ Noob/

    -d "var1=foo&var2=bar" • curl -XPOST http://phpqueuedemo.azurewebsites.net/ Noob/?REQUEST_METHOD=PUT -d "t=meh" • CLI interface • php cli.php Noob add --data '{"name":"Dino Bing"}' • php cli.php Noob work 12 Thursday, 20 December, 12
  9. SMS Worker Single Worker Job Queue Job Job Job Job

    Email Worker Runner SMS Worker Email Worker SMS Worker Email Worker Runner Runner Job 13 Thursday, 20 December, 12
  10. Photo Gallery • Photo uploaded. • File uploaded as a

    Blob. • Pushed to Service Bus Queue. • Worker downloads blob, resize photos and uploads to CDN. • Appears in Gallery. 14 Thursday, 20 December, 12
  11. Usage Model Job Queue Job Job Job Job UploadCDN PhotoResize

    Job 15 DownloadBlob Runner Thursday, 20 December, 12
  12. Best Practices • Use version control wisely, be careful what

    and when u commit. • Use environment variables for deployment specific settings. • Use a build script for post-commit changes, customize your deployment. • Web.config instead of .htaccess. 17 Thursday, 20 December, 12