Do you queue?Characteristics ofscalabilityKevin SchroederTechnology EvangelistZend Technologies                        © A...
About mePast: Programming/Sys AdminCurrent: Technology Evangelist/Author/Composer    @kpschrade                    © All r...
I blog at eschrade.com                         Follow us!                  (good things will happen to you) Zend Technolo...
Twtpoll resultsCould your PHP apps benefit from being able to   process data or execute asynchronously?                  ©...
Why would you want to queue?• Performance   Execute logic apart from the main request (asynchronicity)• Scalability   Th...
Typical anatomy of a PHP Application                      Presentation               Application Control             Bad f...
Someth    Someth    Someth    Someth                                                     Someth    Someth    Someth    Som...
What helps make software scalable?             Defined tasks             Loose coupling          Resource discovery       ...
The Golden Rule of Scalability   “It can probably wait”         © All rights reserved. Zend Technologies, Inc.
Asynchronous execution uses• Pre-caching data• Data analysis• Data processing• Pre-calculating (preparing data for the nex...
Considerations• Waste disk space• Control usage (don’t let users do anything they want)• Pre-calculate as much as possible...
Considerations• Build a deployment mechanism with NO hardcoded values  like directory or resource locations • Make as much...
Options• Use Cron /w PHP CLI (not the best idea)   People mostly use cron simply due to availability     • It’s an availa...
Your only real optionsGearman*                        Zend Server Job QueueFree                            Ready to goLigh...
What the heck is Zend Server?                                                        Zend Server                    Applic...
Job Queue Architecture – Elastic Backend                               Web Server                                         ...
Job Queue Architecture – Elastic Frontend                                                                                 ...
Kevin’s favorite way to implement it• Create a task-handling controller• Create an abstract task class   Understands the ...
Classes involved in the demo  Manager   Handles connecting to the queue and passing results back and forth  JobAbstract ...
Execution Flow 1.   Create job and set data 2.   Execute job      • Job passes itself to the queue manager      • Manager ...
Demo© All rights reserved. Zend Technologies, Inc.
Neato, but how in the worlddoes this pertain to Magento?         © All rights reserved. Zend Technologies, Inc.
How?• Long running front-end requests kill front-end  responsiveness which kills the user experience   40% will wait no m...
Solution?1. Build Zend Server integration extensions     Zendserver_Jobqueue     Zendserver_Monitor2. Utilize the event ...
Building a job• Install the Zend Server Magento extension• Create a class that extends  Zendserver_Jobqueue_JobAbstract• C...
Payment as an example• Hooks an observer into  controller_action_predispatch_checkout_onepage_saveOrder, core_block_abstra...
Scaling the solution             Webserver                                                        Job Queue/              ...
Downloads• Zend Server  http://www.zend.com/server                                                                       ...
Magento/Zend Case Study - http://bit.ly/horpFF                         Follow us! Zend Technologies http://twitter.com/z...
Get this information and all the  examples at eschrade.com…© All rights reserved. Zend Technologies, Inc.
Upcoming SlideShare
Loading in …5
×

Magento's Imagine eCommerce Conference 2011 - Do You Queue?

624 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
624
On SlideShare
0
From Embeds
0
Number of Embeds
102
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • We released Zend Server and Zend Server Community Edition in April this year Products written from scratch based on our very extensive experience with Platform technologies Full integrated stack, native installer, ZF and Studio integration, software updates, all new UI, … Both editions have been very well received by users (love performance boost, ease of use, deployment) Great fit to our partners – we’re working with Varien/Magento, KnowledgeTree, MCS, … Next step will round up web app server offering to support high availability and scalability – more on this in the next few months
  • Magento's Imagine eCommerce Conference 2011 - Do You Queue?

    1. 1. Do you queue?Characteristics ofscalabilityKevin SchroederTechnology EvangelistZend Technologies © All rights reserved. Zend Technologies, Inc.
    2. 2. About mePast: Programming/Sys AdminCurrent: Technology Evangelist/Author/Composer @kpschrade © All rights reserved. Zend Technologies, Inc.
    3. 3. I blog at eschrade.com Follow us! (good things will happen to you) Zend Technologies http://twitter.com/zend http://twitter.com/kpschrade (me!) © All rights reserved. Zend Technologies, Inc.
    4. 4. Twtpoll resultsCould your PHP apps benefit from being able to process data or execute asynchronously? © All rights reserved. Zend Technologies, Inc.
    5. 5. Why would you want to queue?• Performance  Execute logic apart from the main request (asynchronicity)• Scalability  The ability to handle non-immediate logic as resources are available © All rights reserved. Zend Technologies, Inc.
    6. 6. Typical anatomy of a PHP Application Presentation Application Control Bad for Database Access Business Logic scala- Presentation Application Control bility! Business Logic Presentation | © All rights reserved. Zend Technologies, Inc. 6
    7. 7. Someth Someth Someth Someth Someth Someth Someth Someth ing.pht ml ing.pht ml ing.pht ml ing.pht ml Presentation ing.pht ml ing.pht ml ing.pht ml ing.pht ml Good for Application Control Someth Someth Someth Someth Someth Someth Someth Someth ing.php ing.php ing.php ing.php ing.php ing.php ing.php ing.php Someth ing.php Someth ing.php Someth ing.php Scalability Someth ing.php Business Logic Someth ing.php Someth ing.php Someth ing.php Someth ing.php Someth ing.php Someth ing.php Someth ing.php Someth ing.php Database Access Someth ing.php Someth ing.php Someth ing.php Someth ing.php || © All rights reserved. Zend Technologies, Inc. 7
    8. 8. What helps make software scalable? Defined tasks Loose coupling Resource discovery © All rights reserved. Zend Technologies, Inc.
    9. 9. The Golden Rule of Scalability “It can probably wait” © All rights reserved. Zend Technologies, Inc.
    10. 10. Asynchronous execution uses• 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 © All rights reserved. Zend Technologies, Inc.
    11. 11. Considerations• Waste disk space• Control usage (don’t let users do anything they want)• Pre-calculate as much as possible  Calculate and cache/store• Keep data processing off the front end servers• Don’t just cache  Don’t let it substitute for thought  Cache hit rates can be meaningless if you have hundreds of cache hits for a request © All rights reserved. Zend Technologies, Inc.
    12. 12. Considerations• Build a deployment mechanism with NO hardcoded values like directory or resource locations • Make as much as possible configurable/discoverable• Decouple/Partition  Don’t tie everything (relationships and such) into the database• Use queues/messaging  Stomp interfaces are really good for PHP – Can also use Java Bridge  Zend_Queue has several interfaces• Try to use stateless interfaces  (polling is more scalable than idle connections) © All rights reserved. Zend Technologies, Inc.
    13. 13. Options• Use Cron /w PHP CLI (not the best idea)  People mostly use cron simply due to availability • It’s an available option, not necessarily the best option.• Use Gearman• Use home-grown (don’t do this)• Use pcntl_fork() (NEVER do this)• Use Zend Server Job Queue © All rights reserved. Zend Technologies, Inc.
    14. 14. Your only real optionsGearman* Zend Server Job QueueFree Ready to goLightweight Integrates with Event MonitoringOpen Source Integrates with Code Tracing(mostly) language Runs over a widely known protocolagnostic Load distribution can be Very cloud friendlyDistributed queuing accomplished outside of the queue * I am not an expert on Gearman. Corrections will be taken in the spirit that they are given. For obvious reasons, I will focus on Zend Server © All rights reserved. Zend Technologies, Inc.
    15. 15. What the heck is Zend Server? Zend Server Application Reliability & Scale-Out Business-grade Performance Management PHP Acceleration Monitoring Clustering Hot Fixes Optimization Root-Cause Job Queue Support Caching Configuration Downloads Java Bridge Zend Framework PHP Linux Windows IBM i (rpm/web repositories) (MSI) (PTF)15 Zend Server © All rights reserved. Zend Technologies, Inc.
    16. 16. Job Queue Architecture – Elastic Backend Web Server Web Server /w JQ Load Balancer Web Server Users! Web Server /w JQ Web Server Web Server /w JQ• Pros  Scale the backend as necessary  Default (easy) mechanism• Cons  Getting the job status requires using a DB © All rights reserved. Zend Technologies, Inc.
    17. 17. Job Queue Architecture – Elastic Frontend Web Server Web Server /w JQ Load Balancer Web Server Users! Web Server /w JQ Web Server Web Server /w JQ• Pros • Easy to communicate with the Job Queue server handling the jobCons • Requires you to build your own interface (or just use mine!) © All rights reserved. Zend Technologies, Inc.
    18. 18. Kevin’s favorite way to implement it• Create a task-handling controller• Create an abstract task class  Understands the Job Queue  Self contained • If Elastic Backend: connects to localhost • If Elastic Frontend: connects to load balancer (my preferred), load balanced JQ servers manage themselves• Execute the task, have it serialize itself and send it to send to the task handler © All rights reserved. Zend Technologies, Inc.
    19. 19. Classes involved in the demo  Manager Handles connecting to the queue and passing results back and forth  JobAbstract Abstract class that a job would be based off of  Response The response from the manager when a job is queued. Contains the server name and job number  GetRemoteLinks • Scans a given web page and reports back a list of all the links on the page © All rights reserved. Zend Technologies, Inc.
    20. 20. Execution Flow 1. Create job and set data 2. Execute job • Job passes itself to the queue manager • Manager serializes job • Manager uses HTTP call through a load balancer to queue the job • The queue on the other end returns the job id and server name • Job ID and server name is passed to the client 3. Client polls the manager to get a completed job • When the job is returned pass the serialized version of the executed job © All rights reserved. Zend Technologies, Inc.
    21. 21. Demo© All rights reserved. Zend Technologies, Inc.
    22. 22. Neato, but how in the worlddoes this pertain to Magento? © All rights reserved. Zend Technologies, Inc.
    23. 23. How?• Long running front-end requests kill front-end responsiveness which kills the user experience  40% will wait no more than 4 seconds for a website (Forrester)• Calculating cache data on-the-fly can lead to bad user experiences (abruptly slow page load times) and consistency problems• Long running page requests can push up against max_execution_time  For example, handling payments from a slow CC API  Simply setting it to run longer is a band-aid on a broken bone © All rights reserved. Zend Technologies, Inc.
    24. 24. Solution?1. Build Zend Server integration extensions  Zendserver_Jobqueue  Zendserver_Monitor2. Utilize the event system to intercept actions  Async_Payment (for payments, in this case)3. Profit! (scalability AND performance, actually) © All rights reserved. Zend Technologies, Inc.
    25. 25. Building a job• Install the Zend Server Magento extension• Create a class that extends Zendserver_Jobqueue_JobAbstract• Call $job->execute(); © All rights reserved. Zend Technologies, Inc.
    26. 26. Payment as an example• Hooks an observer into controller_action_predispatch_checkout_onepage_saveOrder, core_block_abstract_to _html_after• Checks if a defined template is being rendered• Injects JavaScript that changes the review.save() method• Injects a new URL for submitting the transaction which creates a job  Passes POSTed data to a job• Job executes by submitting the payment URL on behalf of the browser, storing the result• Browser pings the server to see if the job has completed executing yet © All rights reserved. Zend Technologies, Inc.
    27. 27. Scaling the solution Webserver Job Queue/ Webserver Load Balancer Webserver Job Queue/ Webserver Webserver Job Queue/ Webserver* Duplicate deployments onALL machines Database or Session Clustering © All rights reserved. Zend Technologies, Inc.
    28. 28. Downloads• Zend Server  http://www.zend.com/server http://bit.ly/hWJBYw• Zendserver_Jobqueue  https://github.com/kschroeder/Magento-ZendServer-JobQueue• Zendserver_Monitor  https://github.com/kschroeder/Magento-ZendServer-Monitor• Async_Payment  https://github.com/kschroeder/Magento-Async-Payment• Job Queue library & demo  https://github.com/kschroeder/ZendServer-JobQueue-Job-API © All rights reserved. Zend Technologies, Inc.
    29. 29. Magento/Zend Case Study - http://bit.ly/horpFF Follow us! Zend Technologies http://twitter.com/zend http://twitter.com/kpschrade (me!) © All rights reserved. Zend Technologies, Inc.
    30. 30. Get this information and all the examples at eschrade.com…© All rights reserved. Zend Technologies, Inc.

    ×