SlideShare a Scribd company logo
Do you queue? Characteristics of scalabilityKevin SchroederTechnology EvangelistZend Technologies
About me Past: Programming/Sys Admin Current: Technology Evangelist/Author/Composer         @kpschrade
I blog at eschrade.comFollow us!(good things will happen to you)Zend Technologieshttp://twitter.com/zendhttp://twitter.com/kpschrade (me!)
Twtpoll resultsCould your PHP apps benefit from being able to process data or execute asynchronously?
Why would you want to queue?PerformanceExecute logic apart from the main request (asynchronicity)ScalabilityThe ability to handle non-immediate logic as resources are available
Typical anatomy of a PHP ApplicationBad for scala-bility!PresentationApplication ControlDatabase AccessBusiness LogicPresentationApplication ControlBusiness LogicPresentation| 6
Good for ScalabilityPresentationSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlApplication ControlSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpBusiness LogicSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpDatabase AccessSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.php| 7 |   8-Feb-11
What helps make software scalable?Defined tasksLoose couplingResource discovery
The Golden Rule of Scalability“It can probably wait”
Asynchronous execution usesPre-caching dataData analysisData processingPre-calculating (preparing data for the next request)Data is “out of date” once it leaves the web serverImmediacy is seldom necessary
CharacteristicsA sledgehammer can hit a machineScalability and High Availability are yin and yangA site that can’t keep running is not scalableA site that can’t scale will fail (if it gets really popular)Machines can be added and removed at willNot “cloudy” necessarilyNo single point of failureData exists in at least two, preferably at least three, places
ConsiderationsWaste disk spaceControl usage (don’t let users do anything they want)Pre-calculate as much as possibleCalculate and cache/storeKeep data processing off the front end serversDon’t just cacheDon’t let it substitute for thoughtCache hit rates can be meaningless if you have hundreds of cache hits for a request
ConsiderationsBuild a deployment mechanism with NO hardcoded values like directory or resource locations
Make as much as possible configurable/discoverableDecouple/PartitionDon’t tie everything (relationships and such) into the databaseUse queues/messagingStomp interfaces are really good for PHP – Can also use Java BridgeZend_Queue has several interfacesTry to use stateless interfaces(polling is more scalable than idle connections)
OptionsUse Cron /w PHP CLI (not the best idea)People mostly use cron simply due to availabilityIt’s an available option, not necessarily the best option.Use GearmanUse home-grown (don’t do this)Use pcntl_fork() (NEVER do this)Use Zend Server Job Queue
Your only real optionsVery cloud friendly* 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
Zend FrameworkZend ServerPHPApplicationPerformanceReliability &ManagementScale-OutBusiness-gradePHPAccelerationMonitoringClusteringHot FixesOptimizationRoot-CauseJob QueueSupportCachingDownloadsJava BridgeConfigurationLinux(rpm/web repositories)IBM i(PTF)Windows(MSI) What the heck is Zend Server?16Zend Server
Job Queue Architecture – Elastic BackendWeb Server /w JQWeb ServerUsers!Web Server /w JQWeb ServerLoad BalancerWeb Server /w JQWeb ServerProsScale the backend as necessaryDefault (easy) mechanismConsGetting the job status requires using a DB
Job Queue Architecture – Elastic FrontendWeb ServerWeb Server /w JQUsers!Web ServerWeb Server /w JQLoad BalancerWeb ServerWeb Server /w JQProsEasy to communicate with the Job Queue server handling the jobConsRequires you to build your own interface (or just use mine!)
Kevin’s favorite way to implement itCreate a task-handling controllerCreate an abstract task classUnderstands the Job QueueSelf containedIf Elastic Backend: connects to localhostIf Elastic Frontend: connects to load balancer (my preferred), load balanced JQ servers manage themselvesExecute the task, have it serialize itself and send it to send to the task handler
Classes involved in the demoManagerHandles connecting to the queue and passing results back and forthJobAbstractAbstract class that a job would be based off ofResponseThe response from the manager when a job is queued.  Contains the server name and job numberGetRemoteLinksScans a given web page and reports back a list of all the links on the page
Execution FlowCreate job and set dataExecute jobJob passes itself to the queue managerManager serializes jobManager uses HTTP call through a load balancer to queue the jobThe queue on the other end returns the job id and server nameJob ID and server name is passed to the clientClient polls the manager to get a completed jobWhen the job is returned pass the serialized version of the executed job
Demo
Neato, but how in the world does this pertain to Magento?
How?Long running front-end requests kill front-end responsiveness which kills the user experience40% 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 problemsLong running page requests can push up against max_execution_timeFor example, handling payments from a slow CC APISimply setting it to run longer is a band-aid on a broken bone
Solution?Build Zend Server integration extensionsZendserver_JobqueueZendserver_MonitorUtilize the event system to intercept actionsAsync_Payment  (for payments, in this case)Profit! (scalability AND performance, actually)
Building a jobInstall the Zend Server Magento extensionCreate a class that extends Zendserver_Jobqueue_JobAbstractCall $job->execute();
Payment as an exampleHooks an observer into controller_action_predispatch_checkout_onepage_saveOrder, core_block_abstract_to_html_afterChecks if a defined template is being renderedInjects JavaScript that changes the review.save() methodInjects a new URL for submitting the transaction which creates a jobPasses POSTed data to a jobJob executes by submitting the payment URL on behalf of the browser, storing the resultBrowser pings the server to see if the job has completed executing yet
Scaling the solutionWebserverJob Queue/ WebserverWebserverLoad BalancerJob Queue/ WebserverWebserverJob Queue/ Webserver* Duplicate deployments on ALL machinesDatabase or Session Clustering
DownloadsZend Serverhttp://www.zend.com/serverZendserver_Jobqueuehttps://github.com/kschroeder/Magento-ZendServer-JobQueueZendserver_Monitorhttps://github.com/kschroeder/Magento-ZendServer-MonitorAsync_Paymenthttps://github.com/kschroeder/Magento-Async-PaymentJob Queue library & demohttps://github.com/kschroeder/ZendServer-JobQueue-Job-APIhttp://bit.ly/hWJBYw
Magento/Zend Case Study - http://bit.ly/horpFFFollow us!Zend Technologieshttp://twitter.com/zendhttp://twitter.com/kpschrade (me!)

More Related Content

PPTX
Do you queue (updated)
PPTX
ASP.NET MVC Performance
PPT
Automated Testing Of Web Applications Using XML
PPTX
Architecting ASP.NET MVC Applications
PPT
Integration and Acceptance Testing
PPTX
The Windows Runtime and the Web
PPTX
Ajax Load Testing Concerns By Eric Beland
PDF
Selenium Tips & Tricks - StarWest 2015
Do you queue (updated)
ASP.NET MVC Performance
Automated Testing Of Web Applications Using XML
Architecting ASP.NET MVC Applications
Integration and Acceptance Testing
The Windows Runtime and the Web
Ajax Load Testing Concerns By Eric Beland
Selenium Tips & Tricks - StarWest 2015

What's hot (20)

PPTX
Single Page Applications: Your Browser is the OS!
PPTX
My XML is Alive! An Intro to XAML
PPTX
Eric Beland Ajax Load Testing Considerations
PDF
Behavior Driven Development and Automation Testing Using Cucumber
PPTX
SQL Server - CLR integration
PDF
Wordcamp Toronto Presentation
PDF
APIs: A Better Alternative to Page Objects
PPTX
MVC Training Part 2
PDF
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
PDF
Usability in the GeoWeb
PPTX
Dave Orchard - Offline Web Apps with HTML5
PPTX
MVC Training Part 1
PPT
Web performance testing
PPTX
Java Enterprise Performance - Unburdended Applications
PPTX
DSL, Page Object and Selenium – a way to reliable functional tests
PPTX
Getting started with MVC 5 and Visual Studio 2013
KEY
Introduction to ASP.NET MVC
PPTX
Distributed Applications with Perl & Gearman
PPTX
3-TIER ARCHITECTURE IN ASP.NET MVC
PDF
Naked and afraid Offline Mobile
Single Page Applications: Your Browser is the OS!
My XML is Alive! An Intro to XAML
Eric Beland Ajax Load Testing Considerations
Behavior Driven Development and Automation Testing Using Cucumber
SQL Server - CLR integration
Wordcamp Toronto Presentation
APIs: A Better Alternative to Page Objects
MVC Training Part 2
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
Usability in the GeoWeb
Dave Orchard - Offline Web Apps with HTML5
MVC Training Part 1
Web performance testing
Java Enterprise Performance - Unburdended Applications
DSL, Page Object and Selenium – a way to reliable functional tests
Getting started with MVC 5 and Visual Studio 2013
Introduction to ASP.NET MVC
Distributed Applications with Perl & Gearman
3-TIER ARCHITECTURE IN ASP.NET MVC
Naked and afraid Offline Mobile
Ad

Similar to Slideshare - Magento Imagine - Do You Queue (20)

PPTX
Magento's Imagine eCommerce Conference: Do You Queue?
PPTX
Do you queue
PPTX
North east user group tour
ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
PDF
2013 - Dustin whittle - Escalando PHP en la vida real
PPT
Gearman and asynchronous processing in PHP applications
PPT
Gearman and asynchronous processing in PHP applications
PDF
2015 ZendCon - Do you queue
ODP
Scalable Architecture 101
PPT
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
PDF
Queue your work
ODP
Scaling PHP Applications with Zend Platform
PPT
Top 30 Scalability Mistakes
KEY
Work Queues
PPTX
PHP Performance: Principles and tools
ODP
Drupal course - batch API
KEY
Gearman and CodeIgniter
PPTX
Slides from LAX & DEN usergroup meetings
PPTX
Clustered PHP - DC PHP 2009
PPT
Top 10 Scalability Mistakes
Magento's Imagine eCommerce Conference: Do You Queue?
Do you queue
North east user group tour
MNPHP Scalable Architecture 101 - Feb 3 2011
2013 - Dustin whittle - Escalando PHP en la vida real
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
2015 ZendCon - Do you queue
Scalable Architecture 101
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Queue your work
Scaling PHP Applications with Zend Platform
Top 30 Scalability Mistakes
Work Queues
PHP Performance: Principles and tools
Drupal course - batch API
Gearman and CodeIgniter
Slides from LAX & DEN usergroup meetings
Clustered PHP - DC PHP 2009
Top 10 Scalability Mistakes
Ad

More from 10n Software, LLC (10)

PPTX
Delaying Gratification: Using queues to build efficient systems
PPTX
PPTX
Flex and PHP For the Flash Folks
PPTX
Application Deployment with Zend Server 5.5 beta
PPTX
Flex for php developers
PPTX
Creating stunning data analytics dashboard using php and flex
PPTX
Php security common 2011
PPTX
Zend Server - OSI Days
PPTX
Zend Framework Workshop
ODP
Flex and Zend Framework
Delaying Gratification: Using queues to build efficient systems
Flex and PHP For the Flash Folks
Application Deployment with Zend Server 5.5 beta
Flex for php developers
Creating stunning data analytics dashboard using php and flex
Php security common 2011
Zend Server - OSI Days
Zend Framework Workshop
Flex and Zend Framework

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
CIFDAQ's Market Insight: SEC Turns Pro Crypto
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Slideshare - Magento Imagine - Do You Queue

  • 1. Do you queue? Characteristics of scalabilityKevin SchroederTechnology EvangelistZend Technologies
  • 2. About me Past: Programming/Sys Admin Current: Technology Evangelist/Author/Composer @kpschrade
  • 3. I blog at eschrade.comFollow us!(good things will happen to you)Zend Technologieshttp://twitter.com/zendhttp://twitter.com/kpschrade (me!)
  • 4. Twtpoll resultsCould your PHP apps benefit from being able to process data or execute asynchronously?
  • 5. Why would you want to queue?PerformanceExecute logic apart from the main request (asynchronicity)ScalabilityThe ability to handle non-immediate logic as resources are available
  • 6. Typical anatomy of a PHP ApplicationBad for scala-bility!PresentationApplication ControlDatabase AccessBusiness LogicPresentationApplication ControlBusiness LogicPresentation| 6
  • 7. Good for ScalabilityPresentationSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlSomething.phtmlApplication ControlSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpBusiness LogicSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpDatabase AccessSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.phpSomething.php| 7 | 8-Feb-11
  • 8. What helps make software scalable?Defined tasksLoose couplingResource discovery
  • 9. The Golden Rule of Scalability“It can probably wait”
  • 10. Asynchronous execution usesPre-caching dataData analysisData processingPre-calculating (preparing data for the next request)Data is “out of date” once it leaves the web serverImmediacy is seldom necessary
  • 11. CharacteristicsA sledgehammer can hit a machineScalability and High Availability are yin and yangA site that can’t keep running is not scalableA site that can’t scale will fail (if it gets really popular)Machines can be added and removed at willNot “cloudy” necessarilyNo single point of failureData exists in at least two, preferably at least three, places
  • 12. ConsiderationsWaste disk spaceControl usage (don’t let users do anything they want)Pre-calculate as much as possibleCalculate and cache/storeKeep data processing off the front end serversDon’t just cacheDon’t let it substitute for thoughtCache hit rates can be meaningless if you have hundreds of cache hits for a request
  • 13. ConsiderationsBuild a deployment mechanism with NO hardcoded values like directory or resource locations
  • 14. Make as much as possible configurable/discoverableDecouple/PartitionDon’t tie everything (relationships and such) into the databaseUse queues/messagingStomp interfaces are really good for PHP – Can also use Java BridgeZend_Queue has several interfacesTry to use stateless interfaces(polling is more scalable than idle connections)
  • 15. OptionsUse Cron /w PHP CLI (not the best idea)People mostly use cron simply due to availabilityIt’s an available option, not necessarily the best option.Use GearmanUse home-grown (don’t do this)Use pcntl_fork() (NEVER do this)Use Zend Server Job Queue
  • 16. Your only real optionsVery cloud friendly* 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
  • 17. Zend FrameworkZend ServerPHPApplicationPerformanceReliability &ManagementScale-OutBusiness-gradePHPAccelerationMonitoringClusteringHot FixesOptimizationRoot-CauseJob QueueSupportCachingDownloadsJava BridgeConfigurationLinux(rpm/web repositories)IBM i(PTF)Windows(MSI) What the heck is Zend Server?16Zend Server
  • 18. Job Queue Architecture – Elastic BackendWeb Server /w JQWeb ServerUsers!Web Server /w JQWeb ServerLoad BalancerWeb Server /w JQWeb ServerProsScale the backend as necessaryDefault (easy) mechanismConsGetting the job status requires using a DB
  • 19. Job Queue Architecture – Elastic FrontendWeb ServerWeb Server /w JQUsers!Web ServerWeb Server /w JQLoad BalancerWeb ServerWeb Server /w JQProsEasy to communicate with the Job Queue server handling the jobConsRequires you to build your own interface (or just use mine!)
  • 20. Kevin’s favorite way to implement itCreate a task-handling controllerCreate an abstract task classUnderstands the Job QueueSelf containedIf Elastic Backend: connects to localhostIf Elastic Frontend: connects to load balancer (my preferred), load balanced JQ servers manage themselvesExecute the task, have it serialize itself and send it to send to the task handler
  • 21. Classes involved in the demoManagerHandles connecting to the queue and passing results back and forthJobAbstractAbstract class that a job would be based off ofResponseThe response from the manager when a job is queued. Contains the server name and job numberGetRemoteLinksScans a given web page and reports back a list of all the links on the page
  • 22. Execution FlowCreate job and set dataExecute jobJob passes itself to the queue managerManager serializes jobManager uses HTTP call through a load balancer to queue the jobThe queue on the other end returns the job id and server nameJob ID and server name is passed to the clientClient polls the manager to get a completed jobWhen the job is returned pass the serialized version of the executed job
  • 23. Demo
  • 24. Neato, but how in the world does this pertain to Magento?
  • 25. How?Long running front-end requests kill front-end responsiveness which kills the user experience40% 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 problemsLong running page requests can push up against max_execution_timeFor example, handling payments from a slow CC APISimply setting it to run longer is a band-aid on a broken bone
  • 26. Solution?Build Zend Server integration extensionsZendserver_JobqueueZendserver_MonitorUtilize the event system to intercept actionsAsync_Payment (for payments, in this case)Profit! (scalability AND performance, actually)
  • 27. Building a jobInstall the Zend Server Magento extensionCreate a class that extends Zendserver_Jobqueue_JobAbstractCall $job->execute();
  • 28. Payment as an exampleHooks an observer into controller_action_predispatch_checkout_onepage_saveOrder, core_block_abstract_to_html_afterChecks if a defined template is being renderedInjects JavaScript that changes the review.save() methodInjects a new URL for submitting the transaction which creates a jobPasses POSTed data to a jobJob executes by submitting the payment URL on behalf of the browser, storing the resultBrowser pings the server to see if the job has completed executing yet
  • 29. Scaling the solutionWebserverJob Queue/ WebserverWebserverLoad BalancerJob Queue/ WebserverWebserverJob Queue/ Webserver* Duplicate deployments on ALL machinesDatabase or Session Clustering
  • 31. Magento/Zend Case Study - http://bit.ly/horpFFFollow us!Zend Technologieshttp://twitter.com/zendhttp://twitter.com/kpschrade (me!)
  • 32. Get this information and all the examples at eschrade.com…

Editor's Notes

  • #17: 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