Top Banner
Delayed operations with queues Yuriy Gerasimov Frédéric G. Marand
17

Юрій Герасимов — Delayed operations with queues

Jan 22, 2017

Download

Internet

LEDC 2016
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Юрій Герасимов — Delayed operations with queues

Delayed operations with queues

Yuriy Gerasimov Frédéric G. Marand

Page 2: Юрій Герасимов — Delayed operations with queues

Yuriy Gerasimov ygerasimov

• FFW

• Drupal architect & developer

• Contrib 7 modules: services, draggableviews

• Founder at Backtrac.io

Page 3: Юрій Герасимов — Delayed operations with queues

Frédéric G. Marand fgm

• OSInet: performance/architecture consulting

• for internal teams at larger accounts

• Core contributor 4.7 to 8.0.x, MongoDB + XMLRPC maintainer + others

• Already 4 D8 customer projects before 8.0.0

• Customer D8 in production since 07/2015

• Frequently adds queueing to larger Drupal projects

Page 4: Юрій Герасимов — Delayed operations with queues

Why use queues ?To have websites which are :

• Faster for visitors

• Snappier for editors

• More scaleable

To process time-consuming jobs :

• Video encoding

• High-resolution gallery uploads and processing

Page 5: Юрій Герасимов — Delayed operations with queues

Concrete use cases• Prepare content for non-Drupal front-ends

• Anticipate content generation

• Deferred submits, e.g. comments handling

• Slow operations: node saves, previews, image processing

• External data sources: pull, push

• Multi-step operations: batch

Page 6: Юрій Герасимов — Delayed operations with queues

Cooking for front-ends

Page 7: Юрій Герасимов — Delayed operations with queues

Anticipated content generation

Page 8: Юрій Герасимов — Delayed operations with queues

Comment handling

Page 9: Юрій Герасимов — Delayed operations with queues

“Pull” data sources (aggregator)

Page 10: Юрій Герасимов — Delayed operations with queues

“Push” data sources

Page 11: Юрій Герасимов — Delayed operations with queues

Image processing

Page 12: Юрій Герасимов — Delayed operations with queues

Job servers• How to get results

• Rerun failed jobs

• Separate queue for failed jobs

• Monitoring queues, workers

• Supervisor

Page 13: Юрій Герасимов — Delayed operations with queues

Some implementations

Page 14: Юрій Герасимов — Delayed operations with queues

Queue API methods: QueueQueueInterface

• Q::createItem(mixed $data: void

• Q::claimItem($lease_time = 3600: mixed $item

FALSE | stdClass + [item_id => int, data => mixed, created => timestamp]

$lease_time → Assumptions for runner, currently not used

• Q::deleteItem($item): void -> work done

• Q::releaseItem($item): bool

• Q::numberOfItems(): int → best guess, unreliable

• Q::createQueue() / Q::deleteQueue()

ReliableQueueInterface: ordering, single execution

Page 15: Юрій Герасимов — Delayed operations with queues

Queue RunnersCore / Contrib

• Core Cron / Elysia Cron / Queue_Runner

• Drush: queue-list / queue-run

Similar limitations:

• Default on in D6 / D7, default off in D8

• Single threaded, single process across queues

Custom runners

• Provided by queue modules or per-project one-offs

• Preemption, parallel execution...

Page 16: Юрій Герасимов — Delayed operations with queues

Queue API limitations• Exception handling

• Priority management

• Tagging

• Delay, burying ...

• No monitoring, peek(), deduplication

Page 17: Юрій Герасимов — Delayed operations with queues

Questions ?