Do You Queue? An introduction to the Zend Server Job Queue

Do You Queue? An introduction to the Zend Server Job Queue

There has been a lot of talk over the past several years about the difference between performance and scalability. When talking about building a scalable application queuing is a concept that many PHP developers are not overly familiar with. In this talk we will demonstrate how you can use some generic principles, implemented in the Zend Server Job Queue to help scale your application.

730881744ee7e4c53dacf6e421d0dce5?s=128

Slavey Karadzhov

October 24, 2012
Tweet

Transcript

  1. © All rights reserved. Zend Technologies, Inc. Do you queue?

    An introduction to the Zend Server Job Queue Slavey Karadzhov Senior Consultant Zend Technologies Credits: Eric Ritchie, Kevin Schroeder
  2. © All rights reserved. Zend Technologies, Inc. About me •

    Senior Technical Consultant and Trainer at Zend Technologies • Zend Framework and PHP 5.3 ZCE • Many years of PHP (v3,4 & 5), ZF 1 and galaxy of programming languages (Python, Perl, Java, JavaScript,…). • Hobbies: Travelling, sampling exotic dishes, outdoor sports, testing hype technologies. (in no particular order) 2
  3. © All rights reserved. Zend Technologies, Inc. Agenda • Asynchronous

    operations in PHP • Performance and Scalability • Zend Server Job Queue • Benchmarks • Use Cases • Implementation with Zend Server Job Queue • Questions & Answers 3
  4. © All rights reserved. Zend Technologies, Inc. Asynchronous operations in

    PHP Meaning and implications
  5. © All rights reserved. Zend Technologies, Inc. Asynchronous operations in

    PHP • PHP is a sequential language  Step by step execution (synchronous)  Time consuming tasks delay the complete execution  Pro: Simplicity  Con: Performance and scalability issues 5
  6. © All rights reserved. Zend Technologies, Inc. Asynchronous operations in

    PHP Could your PHP apps benefit from being able to process data or execute asynchronously? 6
  7. © All rights reserved. Zend Technologies, Inc. Asynchronous operations in

    PHP • Why would you want to use them?  Performance • Execute logic apart from the main request  Scalability • The ability to handle non-immediate logic as resources are available 7
  8. © All rights reserved. Zend Technologies, Inc. Performance & Scalability

  9. © All rights reserved. Zend Technologies, Inc. Performance & Scalability

    • Performance is the speed by which a request is executed • Scalability is the ability of that request to maintain its performance as load/infrastructure increases Scalability can be improved by better performance but they are not the same 9
  10. © All rights reserved. Zend Technologies, Inc. Performance & Scalability

    • Improving the performance can mean  Make the PHP run faster  Make the PHP use less resources (hardware, network bandwidth ) • Improving the scalability can mean  Be able to handle more users  Be able to handle more data  Be able to handle more operations 10
  11. © All rights reserved. Zend Technologies, Inc. Performance & Scalability

    • What helps make software scalable?  Defined tasks  Loose coupling  Resource discovery 11
  12. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue
  13. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue 13
  14. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue • Facilitates the PHP developers in executing asynchronous tasks • Benefits  Reduce application bottlenecks  Improve the end-user experience  Intelligently distribute load across multiple servers  Appropriately schedule non-time-sensitive tasks 14
  15. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue • Perfect integration with  Management  Monitoring 15
  16. © All rights reserved. Zend Technologies, Inc. Demonstration >>

  17. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue 17
  18. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue • Put certain tasks into a separate execution queue  Off-load to new process (or defer to a later time)  Off-load to a different server • Schedule jobs in the future  Distribute processing load to off-hours • Set recurring jobs • Execute immediately, as resources are available • Utilize ZendJobQueue() 18
  19. © All rights reserved. Zend Technologies, Inc. Zend Server Job

    Queue • Jobs are created using the createHttpJob() method • Pass parameters  Simple ones, via query string $_GET  Complex ones, as an associative array of key => value pairs • Set job options  Name, priority, schedule, etc.  Create deferred or recurring jobs • •Or… create from the UI 19
  20. © All rights reserved. Zend Technologies, Inc. Benchmarks Why using

    Zend Job Queue matters?
  21. © All rights reserved. Zend Technologies, Inc. Benchmarks • Sending

    Emails 22
  22. © All rights reserved. Zend Technologies, Inc. Benchmarks • Image

    conversion using ImageMagick 23
  23. © All rights reserved. Zend Technologies, Inc. Use Cases In

    which situations you can get the most of out of Zend Server Job Queue
  24. © All rights reserved. Zend Technologies, Inc. Use Cases •

    Pre-caching data • Data analysis • Data processing • Pre-calculating (preparing data for the next request) Data is “out of date” once it leaves the web server Immediacy is seldom necessary 25
  25. © All rights reserved. Zend Technologies, Inc. Implementation with Zend

    Server Job Queue The time for coding comes …
  26. © All rights reserved. Zend Technologies, Inc. Implementation with Zend

    Server Job Queue • Execute single job • Execute recurring job • Execute job on all Zend Server clustered nodes 27
  27. © All rights reserved. Zend Technologies, Inc. Thanks you! And

    now time for questions. Or write me at slavey@zend.com
  28. © All rights reserved. Zend Technologies, Inc. Follow us! 

    http://www.facebook.com/ZendTechnologies  http://twitter.com/zend