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

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.

Slavey Karadzhov

October 24, 2012
Tweet

More Decks by Slavey Karadzhov

Other Decks in Programming

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

    View Slide

  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

    View Slide

  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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  15. © All rights reserved. Zend Technologies, Inc.
    Zend Server Job Queue
    • Perfect integration with
     Management
     Monitoring
    15

    View Slide

  16. © All rights reserved. Zend Technologies, Inc.
    Demonstration >>

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  20. © All rights reserved. Zend Technologies, Inc.
    Benchmarks
    Why using Zend Job Queue matters?

    View Slide

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

    View Slide

  22. © All rights reserved. Zend Technologies, Inc.
    Benchmarks
    • Image conversion using ImageMagick
    23

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

  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

    View Slide

  27. © All rights reserved. Zend Technologies, Inc.
    Thanks you!
    And now time for questions.
    Or write me at [email protected]

    View Slide

  28. © All rights reserved. Zend Technologies, Inc.
    Follow us!
     http://www.facebook.com/ZendTechnologies
     http://twitter.com/zend

    View Slide