Delaying Gratification: Using queues to build efficient systems

Preview:

Citation preview

Delaying GratificationUsing 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.

Tom Lodge

Senior Magento eCommerce Architect Magento ECGtlodge@ebay.com

Kevin Schroeder

Technical Manager of Education and Consulting

Magento ECG, MagentoU

keschroeder@ebay.com

@kpschrade

Business Case1

Welcome to BillyBobBBQs.com

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

The Board Expects

• Optimal Customer Experience• Maximise Sales• Minimise Costs

Simple stuff

• Payment Gateway• ERP Integration• Third Party Systems

Marketing promotes success

• BillyBobBBQs.com have a great PR team• PR aren’t always able to predict success• Chairman on Good Morning America

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

OK so what next…

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

Thinking About The Problem2

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

Billy Bob’s scaling experience

1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52

Solution: Cloud

Server

Server

Timeline

Two Problems

1: Clouds still like predictability

Throughput

Capacity

2: We’ve only scaled web nodes

Server

Server

Server

Server

Server

Server

Server

Database

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

Defining A Solution3

Requirements

• MUST handle spikes without interfering with the customer

• MUST mitigate spikes without overwhelming the infrastructure

• MUST be able to use resources efficiently

Billy Bob needs a system like this

Throughput

Capacity

Options

Batching Queuing

Difference between batch and queue

Batch Queue

Difference between batch and queue

Batch Queue

Difference between batch and queue

Batch Queue

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

Batching QueuingQu

Implementing A Solution4

Front End Node

Worker Queue

Basic Work Flow

MUST handle spikes without interfering with the customer

MUST be able to use resources efficiently

MUST mitigate spikes without overwhelming the infrastructure

Uni-Directional Job

Executed On The Frontend

Executed On The BackendUnit Testing Entry Point

Eg. 1 – Uni-Directional5

Bi-Directional Job

Executed In The Future

Bi-Directional Result Tickets

Get a result ticket

Job is returned when it has finished executing

Eg.2 – Bi-DirectionalBlocking/Non-Blocking

6

Integration with Magento7

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?

https://github.com/kschroeder/Magento-Worker-Queue_POC

Questions9

Thanks

Tom LodgeSenior Magento eCommerce Architect

Magento ECG

tlodge@ebay.com

Kevin SchroederTechnical Manager of Education and Consulting

Magento ECG, MagentoU

keschroeder@ebay.com

@kpschrade

Recommended