Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
High availability by offloading work - backgrou...
Search
Kerstin Puschke
September 20, 2019
Technology
0
410
High availability by offloading work - background jobs, message queues, or Kafka
Talk at RubyConf Colombia 2019
Kerstin Puschke
September 20, 2019
Tweet
Share
More Decks by Kerstin Puschke
See All by Kerstin Puschke
Background jobs at scale (Montreal.rb)
titanoboa
0
330
EuRuKo 2018: Scaling a monolith isn't scaling microservices
titanoboa
2
120
Background jobs at scale
titanoboa
1
58
Background jobs at scale
titanoboa
0
53
Decouple all the things: Asynchronous messaging keeps it simple
titanoboa
0
110
Decouple all the things - Asynchronous messaging keeps it simple
titanoboa
0
81
Decouple all the things - asynchronous messaging keeps it simple
titanoboa
0
430
Decouple all the things - asynchronous messaging keeps it simple
titanoboa
0
570
No RSVP required: Asynchronous Messaging
titanoboa
0
300
Other Decks in Technology
See All in Technology
OPENLOGI Company Profile for engineer
hr01
1
12k
ガバメントクラウド開発と変化と成長する組織 / Organizational change and growth in developing a government cloud
kazeburo
4
750
入門 KRR
donkomura
0
110
小さな勉強会の始め方、広げ方、あるいは友達の作り方 / How to Start, Grow, and Build Connections with Small Study Groups
ar_tama
6
2.7k
【完全版】Dify - LINE Bot連携 考え方と実用テクニック
uezo
1
230
ドキュメントとの付き合い方を考える
leveragestech
1
130
AWSへのNIST SP800-171管理策 導入に向けての整備/20240930 Mitsutoshi Matsuo
shift_evolve
0
200
ラブグラフ紹介資料 〜プロダクト解体新書〜 / Lovegraph Product Deck
lovegraph
0
14k
リスクから学ぶKubernetesコンテナセキュリティ/k8s-risk-and-security
mochizuki875
1
320
エムスリー全チーム紹介資料 / Introduction of M3 All Teams
m3_engineering
1
310
プロダクト開発の貢献をアピールするための目標設計や認知活動 / Goal design and recognition activities to promote product development contributions.
oomatomo
4
770
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
400
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Testing 201, or: Great Expectations
jmmastey
38
7k
Side Projects
sachag
452
42k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
110
6.9k
Clear Off the Table
cherdarchuk
91
320k
Optimizing for Happiness
mojombo
375
69k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
7
580
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
105
48k
Transcript
Kerstin Puschke @titanoboa42 High availability by offloading work - background
jobs, message queues, or Kafka
@titanoboa42
@titanoboa42 Different approaches to offload work to ensure high availability
@titanoboa42 • High availability & offloading work Outline
@titanoboa42 • High availability & offloading work • Background jobs
Outline
@titanoboa42 • High availability & offloading work • Background jobs
• Message oriented middleware Outline
@titanoboa42 • Event log Outline
@titanoboa42 • Event log • Summary Outline
@titanoboa42 High availability & offloading work
@titanoboa42 High Availability
@titanoboa42 users can interact with the system High Availability
@titanoboa42 users can interact meaningfully with the system High
Availability
@titanoboa42 community of users can interact meaningfully with the system
High Availability
@titanoboa42 community of users can interact meaningfully with the system
whenever needed High Availability
@titanoboa42 community of users can interact meaningfully with the system
whenever needed High Availability community of users can interact meaningfully with the system whenever needed
@titanoboa42 Background jobs
@titanoboa42 • Resque Background job backends
@titanoboa42 • Resque • Sidekiq Background job backends
@titanoboa42 • Resque • Sidekiq • … Background job backends
@titanoboa42 Background job: Unit of work to be done
later App Server Worker
@titanoboa42 Asynchronous communication App Server Message Queue Worker
@titanoboa42 Asynchronous communication App Server Message Queue Worker Task Queue
@titanoboa42 Asynchronous communication App Server Message Queue Worker Worker Worker
Task Queue
@titanoboa42 Background job backend: task queue & broker
@titanoboa42 Encapsulating async communication
@titanoboa42 Features
@titanoboa42 Task Queue Response times App Server Worker
@titanoboa42 Task Queue Spikeability App Server Worker
@titanoboa42 Task Queue Parallelization App Server Worker Worker Worker
@titanoboa42 Task Queue Retries App Server Worker Worker Worker
@titanoboa42 Mastering challenges
@titanoboa42 Job queued and processed by different versions
@titanoboa42 • No breaking changes to job parameters Job queued
and processed by different versions
@titanoboa42 • No breaking changes to job parameters • Changes
need to be backwards compatible until legacy jobs have been processed Job queued and processed by different versions
@titanoboa42 No exactly once delivery
@titanoboa42 • “At least” vs. “at most” once delivery No
exactly once delivery
@titanoboa42 • “At least” vs. “at most” once delivery •
Idempotent jobs & at least once delivery No exactly once delivery
@titanoboa42 Non-transactional queuing
@titanoboa42 • Don’t queue from within a db transaction Non-transactional
queuing
@titanoboa42 • Don’t queue from within a db transaction •
Job runs before commit, or in case of rollback Non-transactional queuing
@titanoboa42 • Don’t queue from within a db transaction •
Job runs before commit, or in case of rollback • Commit first: Job not guaranteed to be queued Non-transactional queuing
@titanoboa42 Non-transactional queuing
@titanoboa42 • Stage transactionally Non-transactional queuing
@titanoboa42 • Stage transactionally • Scheduler queues job, updates staging
data Non-transactional queuing
@titanoboa42 Local transactions
@titanoboa42 • Eventual consistency at best Local transactions
@titanoboa42 • Eventual consistency at best • SAGA command/orchestration Local
transactions
@titanoboa42 Out of order delivery
@titanoboa42 • SAGA events/choreography: jobs queue jobs Out of order
delivery
@titanoboa42 • SAGA events/choreography: jobs queue jobs • easy to
build, hard to maintain or debug Out of order delivery
@titanoboa42 • SAGA events/choreography: jobs queue jobs • easy to
build, hard to maintain or debug • SAGA command/orchestrator Out of order delivery
@titanoboa42 Long running jobs - Resque
@titanoboa42 • Prevent worker shutdown Long running jobs - Resque
@titanoboa42 • Prevent worker shutdown • No deployments Long running
jobs - Resque
@titanoboa42 • Prevent worker shutdown • No deployments • Not
cloud-friendly Long running jobs - Resque
@titanoboa42 • Aborted and requeued Long running jobs - Sidekiq
@titanoboa42 • Aborted and requeued • Job may not finish
before being aborted again Long running jobs - Sidekiq
@titanoboa42 Large collections
@titanoboa42 • Split job into collection and task to be
done Large collections
@titanoboa42 • Split job into collection and task to be
done • Checkpoint after iteration & requeue Large collections
@titanoboa42 Interruptible job with automatic resuming
@titanoboa42 • Shutdown workers anytime Interruptible job with automatic resuming
@titanoboa42 • Shutdown workers anytime • Disaster prevention Interruptible job
with automatic resuming
@titanoboa42 • Shutdown workers anytime • Disaster prevention • Data
integrity Interruptible job with automatic resuming
@titanoboa42 github.com /Shopify/job-iteration
@titanoboa42 Abstracting scaling issues simplifies concrete background jobs
@titanoboa42 Task Queue Background jobs are ruby objects App Server
Worker
@titanoboa42 Task Queue Background jobs are ruby objects App Server
Worker Broker Broker
@titanoboa42 Offloading work to a worker running the same code
base
@titanoboa42 Background jobs Summary
@titanoboa42 • Based on task queues Background jobs
@titanoboa42 • Based on task queues • Complex overall system,
simple concrete jobs Background jobs
@titanoboa42 • Based on task queues • Complex overall system,
simple concrete jobs • Great for monolith Background jobs
@titanoboa42 Message oriented middleware
@titanoboa42 • Implementations: RabbitMQ, ActiveMQ,… Message oriented middleware
@titanoboa42 • Implementations: RabbitMQ, ActiveMQ,… • Protocols: AMQP, MQTT, Stomp,…
Message oriented middleware
@titanoboa42 Message Queue Messaging Middleware App Server Producer Data-based interface
Worker Consumer
@titanoboa42 Message Queue Messaging Middleware App Server Producer Data-based interface
Worker Consumer Broker
@titanoboa42 Features
@titanoboa42 Commands & Events
@titanoboa42 Propagating updates Business Partners Support Contracts Orders
@titanoboa42 Propagating updates Business Partners Support Contracts Orders
@titanoboa42 Messaging Middleware Resiliency Business Partners Orders
@titanoboa42 Messaging Middleware Resiliency Business Partners
@titanoboa42 Messaging Middleware Resiliency Business Partners Orders
@titanoboa42 Topic with queues provides advanced routing App Server Business
Partners Support Contracts Orders Messaging Middleware
@titanoboa42 Topic with queues provides advanced routing App Server Message
Queue Business Partners Support Contracts Orders Message Queue Messaging Middleware
@titanoboa42 Messaging Middleware Anonymity for producer and consumer Business Partners
Support Contracts Orders
@titanoboa42 Messaging Middleware Anonymity for producer and consumer Business Partners
Invoices Support Contracts Orders
@titanoboa42 Messaging Middleware Anonymity for producer and consumer FraudScore Orders
Support Contracts
@titanoboa42 Messaging Middleware Anonymity for producer and consumer Invoices FraudScore
Orders Support Contracts
@titanoboa42 Mastering challenges
@titanoboa42 Keep breaking changes manageable
@titanoboa42 • Avoid n:m routing Keep breaking changes manageable
@titanoboa42 • Avoid n:m routing • Better representation of domain:
multiple messages routed 1:n, n:1 instead Keep breaking changes manageable
@titanoboa42 • No exactly once delivery Lack of guarantees
@titanoboa42 • No exactly once delivery • No strong consistency
Lack of guarantees
@titanoboa42 • No exactly once delivery • No strong consistency
• Out of order delivery Lack of guarantees
@titanoboa42 No single source of truth
@titanoboa42 • Messages removed after processing No single source of
truth
@titanoboa42 • Messages removed after processing • No replayability No
single source of truth
@titanoboa42 Offloading work to decoupled services with no notion of
system wide state
@titanoboa42 Message oriented middleware Summary
@titanoboa42 • Based on queues and topics Message oriented middleware
@titanoboa42 • Based on queues and topics • Complex overall
system Message oriented middleware
@titanoboa42 • Based on queues and topics • Complex overall
system • Simple message consumers Message oriented middleware
@titanoboa42 • Great for decoupled microservices Message oriented middleware
@titanoboa42 • Great for decoupled microservices • No system wide
state Message oriented middleware
@titanoboa42 Event log
@titanoboa42 • Kafka Event logs
@titanoboa42 • Kafka • … Event logs
@titanoboa42 • Events persisted into append-only log Event log
@titanoboa42 • Events persisted into append-only log • Consumers read
shared log Event log
@titanoboa42 • Events persisted into append-only log • Consumers read
shared log • Stateless broker (no queues) Event log
@titanoboa42 High throughput
@titanoboa42 Single source of truth
@titanoboa42 • Events are not removed after processing Single source
of truth
@titanoboa42 • Events are not removed after processing • Replayability
Single source of truth
@titanoboa42 Offloading work to services keeping the notion of system
wide state
@titanoboa42 Event log Summary
@titanoboa42 • Based on shared log, no queues Event logs
@titanoboa42 • Based on shared log, no queues • Complex
overall system Event logs
@titanoboa42 Event logs
@titanoboa42 • Single source of truth (e.g. for event sourcing)
Event logs
@titanoboa42 • Single source of truth (e.g. for event sourcing)
• High throughput applications Event logs
@titanoboa42 Summary
@titanoboa42 • Queues Background jobs
@titanoboa42 • Queues • For monolithic code base Background jobs
@titanoboa42 • Topics and Queues Message oriented middleware
@titanoboa42 • Topics and Queues • For decoupled microservices Message
oriented middleware
@titanoboa42 • Shared log, no queues Event logs
@titanoboa42 • Shared log, no queues • For event sourcing
& high throughput applications Event logs
@titanoboa42 BFCM video
@titanoboa42 BFCM video
Thanks! Questions? @titanoboa42 https://www.shopify.com/careers