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
Running Jobs at Scale
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kir Shatrov
June 16, 2018
Programming
1
210
Running Jobs at Scale
My talk from GORUCO 2018 in New York.
Kir Shatrov
June 16, 2018
Tweet
Share
More Decks by Kir Shatrov
See All by Kir Shatrov
Operating Rails in Kubernetes
kirs
3
480
RailsClub 2016
kirs
2
320
Performance regressions in Ruby on Rails Core
kirs
0
220
Building a toolkit to detect performance regressions in Ruby on Rails core
kirs
3
5.8k
Развертывание веб-приложений и фреймворк Capistrano
kirs
1
290
Capistrano 3
kirs
4
2.9k
Other Decks in Programming
See All in Programming
CSC307 Lecture 04
javiergs
PRO
0
650
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
170
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
700
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
180
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
160
ThorVG Viewer In VS Code
nors
0
750
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
280
Data-Centric Kaggle
isax1015
2
700
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.7k
Graviton と Nitro と私
maroon1st
0
170
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
120
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
190
Featured
See All Featured
Are puppies a ranking factor?
jonoalderson
1
2.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
530
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
250
Building a Scalable Design System with Sketch
lauravandoore
463
34k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
410
Color Theory Basics | Prateek | Gurzu
gurzu
0
180
It's Worth the Effort
3n
188
29k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
200
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
55
Transcript
Running Jobs at Scale Kir Shatrov GORUCO 2018, @kirshatrov
GORUCO 2018, @kirshatrov
GORUCO 2018, @kirshatrov
GORUCO 2018, @kirshatrov
GORUCO 2018, @kirshatrov
Jobs GORUCO 2018, @kirshatrov
class ExampleJob < ActiveJob::Base def perform ... end end GORUCO
2018, @kirshatrov
class ExampleJob < ActiveJob::Base def perform Product.all.find_each do |product| product.sync_and_refresh
end end end GORUCO 2018, @kirshatrov
class ExampleJob < ActiveJob::Base def perform Product.all.find_each do |product| product.sync_and_refresh
end end end minutes? hours? days? GORUCO 2018, @kirshatrov
Long-running jobs GORUCO 2018, @kirshatrov
Long-running jobs — Deploys and termination GORUCO 2018, @kirshatrov
Long-running jobs — Deploys and termination — Abort and re-enqueue
— Progress lost GORUCO 2018, @kirshatrov
GORUCO 2018, @kirshatrov
Long-running jobs — Deploys and termination — Abort and re-enqueue
— Progress lost — Job may never complete GORUCO 2018, @kirshatrov
Long-running jobs — Deploys and termination — Abort and re-enqueue
— Progress lost — Job may never complete — Capacity and worker starvation GORUCO 2018, @kirshatrov
Long-running jobs — Deploys and termination — Abort and re-enqueue
— Progress lost — Job may never complete — Capacity and worker starvation — Cloud ☁ GORUCO 2018, @kirshatrov
Why is it taking long? Because it iterates over a
long collection. GORUCO 2018, @kirshatrov
What if jobs were interruptible and resumable? GORUCO 2018, @kirshatrov
Split the job definition 1. Collection to process 2. Work
to be done GORUCO 2018, @kirshatrov
Split the job definition 1. Collection to process ≫ Product.all
2. Work to be done GORUCO 2018, @kirshatrov
Split the job definition 1. Collection to process ≫ Product.all
2. Work to be done ≫ product.sync_and_refresh GORUCO 2018, @kirshatrov
class ExampleJob < ActiveJob::Base include Iteration def collection Product.all end
def each_iteration(product) product.sync_and_refresh end end GORUCO 2018, @kirshatrov
— def perform — collection — each_iteration GORUCO 2018, @kirshatrov
Product.all cursor: 1 GORUCO 2018, @kirshatrov
Product.all cursor: 2 GORUCO 2018, @kirshatrov
Product.all cursor: 3 GORUCO 2018, @kirshatrov
Product.all cursor: 4 GORUCO 2018, @kirshatrov
Product.all cursor: 5 GORUCO 2018, @kirshatrov
Product.all cursor: 450123 GORUCO 2018, @kirshatrov
class WhateverJob < ActiveJob::Base include Iteration def collection Enumerator.new do
|enum| 3.times do |n| enum << n end end end def each_iteration(n) # do something three times! end end GORUCO 2018, @kirshatrov
Endless possibilities — Interrupt and resume at any moment —
Progress tracking — Parallel computations — Throttling by default GORUCO 2018, @kirshatrov
Benefits for the infrastructure — Keep supporting long-running jobs —
Success for Cloud runtime — Make scale invisible for developers — Opportunities to save money with short-living instances in Cloud GORUCO 2018, @kirshatrov
Thank you! @kirshatrov GORUCO 2018, @kirshatrov