delaying gratification: using queues to build efficient systems
TRANSCRIPT
![Page 1: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/1.jpg)
![Page 2: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/2.jpg)
Delaying GratificationUsing queues to build efficient systems
![Page 3: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/3.jpg)
Copyright © 2014 Magento, Inc. All Rights Reserved.
Magento®, eBay Enterprise™ and their respective logos are trademarks, service marks, registered trademarks, or registered service marks of eBay, Inc. or its subsidiaries. Other trademarks or service marks contained in this presentation are the property of the respective companies with which they are associated.
This presentation is for informational and discussion purposes only and should not be construed as a commitment of Magento, Inc. or GSI Commerce, Inc. d/b/a eBay Enterprise (“eBay Enterprise”) or of any of their subsidiaries or affiliates. While we attempt to ensure the accuracy, completeness and adequacy of this presentation, neither Magento, Inc., eBay Enterprise nor any of their subsidiaries or affiliates are responsible for any errors or will be liable for the use of, or reliance upon, this presentation or any of the information contained in it. Unauthorized use, disclosure or dissemination of this information is expressly prohibited.
![Page 5: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/5.jpg)
Kevin Schroeder
Technical Manager of Education and Consulting
Magento ECG, MagentoU
@kpschrade
![Page 6: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/6.jpg)
Business Case1
![Page 7: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/7.jpg)
Welcome to BillyBobBBQs.com
• BillyBobBBQs.com• Sell BBQs• Sell a LOT of BBQs
![Page 8: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/8.jpg)
The Board Expects
• Optimal Customer Experience• Maximise Sales• Minimise Costs
![Page 9: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/9.jpg)
Simple stuff
• Payment Gateway• ERP Integration• Third Party Systems
![Page 10: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/10.jpg)
Marketing promotes success
• BillyBobBBQs.com have a great PR team• PR aren’t always able to predict success• Chairman on Good Morning America
![Page 11: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/11.jpg)
Success can be a problem
• Site designed for a volume of traffic• Chairman just invited USA to visit• Site needs to scale • Max Sales, Min Cost
![Page 12: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/12.jpg)
OK so what next…
• Maintain Customer Experience• Maximise Sales• Minimise Costs• Handle Spikes
![Page 13: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/13.jpg)
Thinking About The Problem2
![Page 14: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/14.jpg)
How we (like to) think about scaling
1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 960
1
2
3
4
5
6
7
0
50
100
150
200
250
300
350
400
Capacity
Traffic
![Page 15: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/15.jpg)
Billy Bob’s scaling experience
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52
![Page 16: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/16.jpg)
Solution: Cloud
Server
Server
Timeline
![Page 17: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/17.jpg)
Two Problems
![Page 18: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/18.jpg)
1: Clouds still like predictability
Throughput
Capacity
![Page 19: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/19.jpg)
2: We’ve only scaled web nodes
Server
Server
Server
Server
Server
Server
Server
Database
![Page 20: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/20.jpg)
What does Billy Bob need?
A system that can temporarily manage peaks that are beyond the synchronous capacity of the system
while retaining functionality and responsiveness
In other words we are talking about scalability not performance
![Page 21: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/21.jpg)
Defining A Solution3
![Page 22: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/22.jpg)
Requirements
• MUST handle spikes without interfering with the customer
• MUST mitigate spikes without overwhelming the infrastructure
• MUST be able to use resources efficiently
![Page 23: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/23.jpg)
Billy Bob needs a system like this
Throughput
Capacity
![Page 24: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/24.jpg)
Options
Batching Queuing
![Page 25: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/25.jpg)
Difference between batch and queue
Batch Queue
![Page 26: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/26.jpg)
Difference between batch and queue
Batch Queue
![Page 27: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/27.jpg)
Difference between batch and queue
Batch Queue
![Page 28: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/28.jpg)
The Effect on Infrastructure
Batch Queue
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
wa
id
sy
us
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
wa
id
sy
us
![Page 29: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/29.jpg)
Batching QueuingQu
![Page 30: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/30.jpg)
Implementing A Solution4
![Page 31: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/31.jpg)
Front End Node
Worker Queue
Basic Work Flow
![Page 32: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/32.jpg)
MUST handle spikes without interfering with the customer
MUST be able to use resources efficiently
MUST mitigate spikes without overwhelming the infrastructure
![Page 33: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/33.jpg)
Uni-Directional Job
Executed On The Frontend
Executed On The BackendUnit Testing Entry Point
![Page 34: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/34.jpg)
Eg. 1 – Uni-Directional5
![Page 35: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/35.jpg)
Bi-Directional Job
Executed In The Future
![Page 36: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/36.jpg)
Bi-Directional Result Tickets
Get a result ticket
Job is returned when it has finished executing
![Page 37: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/37.jpg)
Eg.2 – Bi-DirectionalBlocking/Non-Blocking
6
![Page 38: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/38.jpg)
Integration with Magento7
![Page 39: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/39.jpg)
How can Billy Bob use this?
1. Initiate jobs at controller_action_predispatch for consumption during
block rendering
2. Execute multiple concurrent data requests from web services
3. Initiate data retrieval for retrieval in subsequent Ajax requests
4. Implement an ordering mechanism that throttles order processing
(beware of PCI issues here, obviously)
5. Update ERP systems immediately with no client interruption
6. Ideas?
![Page 40: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/40.jpg)
https://github.com/kschroeder/Magento-Worker-Queue_POC
![Page 41: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/41.jpg)
Questions9
![Page 42: Delaying Gratification: Using queues to build efficient systems](https://reader038.vdocument.in/reader038/viewer/2022103114/555810d3d8b42a5e468b4825/html5/thumbnails/42.jpg)
Thanks
Tom LodgeSenior Magento eCommerce Architect
Magento ECG
Kevin SchroederTechnical Manager of Education and Consulting
Magento ECG, MagentoU
@kpschrade