42

Delaying Gratification: Using queues to build efficient systems

Embed Size (px)

Citation preview

Page 1: Delaying Gratification: Using queues to build efficient systems
Page 2: Delaying Gratification: Using queues to build efficient systems

Delaying GratificationUsing queues to build efficient systems

Page 3: Delaying Gratification: Using queues to build efficient systems

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 4: Delaying Gratification: Using queues to build efficient systems

Tom Lodge

Senior Magento eCommerce Architect Magento [email protected]

Page 5: Delaying Gratification: Using queues to build efficient systems

Kevin Schroeder

Technical Manager of Education and Consulting

Magento ECG, MagentoU

[email protected]

@kpschrade

Page 6: Delaying Gratification: Using queues to build efficient systems

Business Case1

Page 7: Delaying Gratification: Using queues to build efficient systems

Welcome to BillyBobBBQs.com

• BillyBobBBQs.com• Sell BBQs• Sell a LOT of BBQs

Page 8: Delaying Gratification: Using queues to build efficient systems

The Board Expects

• Optimal Customer Experience• Maximise Sales• Minimise Costs

Page 9: Delaying Gratification: Using queues to build efficient systems

Simple stuff

• Payment Gateway• ERP Integration• Third Party Systems

Page 10: Delaying Gratification: Using queues to build efficient systems

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

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

OK so what next…

• Maintain Customer Experience• Maximise Sales• Minimise Costs• Handle Spikes

Page 13: Delaying Gratification: Using queues to build efficient systems

Thinking About The Problem2

Page 14: Delaying Gratification: Using queues to build efficient systems

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

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

Solution: Cloud

Server

Server

Timeline

Page 17: Delaying Gratification: Using queues to build efficient systems

Two Problems

Page 18: Delaying Gratification: Using queues to build efficient systems

1: Clouds still like predictability

Throughput

Capacity

Page 19: Delaying Gratification: Using queues to build efficient systems

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

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

Defining A Solution3

Page 22: Delaying Gratification: Using queues to build efficient systems

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

Billy Bob needs a system like this

Throughput

Capacity

Page 24: Delaying Gratification: Using queues to build efficient systems

Options

Batching Queuing

Page 25: Delaying Gratification: Using queues to build efficient systems

Difference between batch and queue

Batch Queue

Page 26: Delaying Gratification: Using queues to build efficient systems

Difference between batch and queue

Batch Queue

Page 27: Delaying Gratification: Using queues to build efficient systems

Difference between batch and queue

Batch Queue

Page 28: Delaying Gratification: Using queues to build efficient systems

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

Batching QueuingQu

Page 30: Delaying Gratification: Using queues to build efficient systems

Implementing A Solution4

Page 31: Delaying Gratification: Using queues to build efficient systems

Front End Node

Worker Queue

Basic Work Flow

Page 32: Delaying Gratification: Using queues to build efficient systems

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

Uni-Directional Job

Executed On The Frontend

Executed On The BackendUnit Testing Entry Point

Page 34: Delaying Gratification: Using queues to build efficient systems

Eg. 1 – Uni-Directional5

Page 35: Delaying Gratification: Using queues to build efficient systems

Bi-Directional Job

Executed In The Future

Page 36: Delaying Gratification: Using queues to build efficient systems

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

Eg.2 – Bi-DirectionalBlocking/Non-Blocking

6

Page 38: Delaying Gratification: Using queues to build efficient systems

Integration with Magento7

Page 39: Delaying Gratification: Using queues to build efficient systems

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://github.com/kschroeder/Magento-Worker-Queue_POC

Page 41: Delaying Gratification: Using queues to build efficient systems

Questions9

Page 42: Delaying Gratification: Using queues to build efficient systems

Thanks

Tom LodgeSenior Magento eCommerce Architect

Magento ECG

[email protected]

Kevin SchroederTechnical Manager of Education and Consulting

Magento ECG, MagentoU

[email protected]

@kpschrade