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
background job patterns
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Matt Yoho
May 23, 2012
Programming
510
2
Share
background job patterns
Matt Yoho
May 23, 2012
More Decks by Matt Yoho
See All by Matt Yoho
Working with Git and GitHub
mattyoho
4
320
Qualitative Analysis of Algorithms
mattyoho
5
430
Metaprogramming Ruby
mattyoho
19
690
Exploiting The Resource Idiom
mattyoho
2
410
testing revisited - outside-in
mattyoho
1
130
shared_auth.pdf
mattyoho
0
2.3k
Request-Response cycle
mattyoho
5
190
Intro to Rest
mattyoho
6
590
Other Decks in Programming
See All in Programming
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
2
310
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
Moments When Things Go Wrong
aurimas
3
140
New "Type" system on PicoRuby
pocke
1
450
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
430
RTSPクライアントを自作してみた話
simotin13
0
440
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
580
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
280
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
480
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
140
JavaDoc 再入門
nagise
0
270
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
The Curious Case for Waylosing
cassininazir
1
370
Typedesign – Prime Four
hannesfritz
42
3.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
A Modern Web Designer's Workflow
chriscoyier
698
190k
WENDY [Excerpt]
tessaabrams
11
38k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Deep Space Network (abreviated)
tonyrice
0
160
Done Done
chrislema
186
16k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Transcript
Approaches to Background Jobs Wednesday, May 23, 12
Architectures Wednesday, May 23, 12
“one soul, two bodies” Wednesday, May 23, 12
Wednesday, May 23, 12
prenuptial agreement Wednesday, May 23, 12
Wednesday, May 23, 12
Types of Jobs Wednesday, May 23, 12
Run-once (Resque, DelayedJob) Wednesday, May 23, 12
Event occurs, job enqueued Worker instantiate job model Load AR
object(s) model Create AR object(s) Hit API job {id, token} job goes away Wednesday, May 23, 12
Recurring jobs (Recursive queuing) Wednesday, May 23, 12
Event occurs, job enqueued Worker instantiate job model Load AR
object(s) model Create AR object(s) Hit API job {id, token} Wait 90s re-enqueue self Wednesday, May 23, 12
Scheduled jobs (resque-scheduler, cron) Wednesday, May 23, 12
Event occurs, job scheduled Worker instantiate job model Load AR
object(s) model Create AR object(s) Hit API job {id, token} job goes away 90s enqueue job Wednesday, May 23, 12
CancelAbandonedOrders: cron: "*/5 * * * *" clear_leaderboards_contributors: cron: "30
6 * * 1" class: ClearLeaderboards queue: low args: contributors description: "Reset the weekly leaders" Wednesday, May 23, 12
Approach can work, but is a bit kludgy Wednesday, May
23, 12
Difficult or impossible to adjust intervals programmatically (dynamically) Wednesday, May
23, 12
May want to respond to traffic, load, rate-limiting, by adding
or subtracting workers, changing interval Wednesday, May 23, 12
Are we meeting the SLA? Wednesday, May 23, 12
Service Level Agreement Wednesday, May 23, 12
Service Level Agreement “At least every 5 minutes” Wednesday, May
23, 12
Hypothetical: SLA: 30 seconds Mean job time: 5 seconds Wednesday,
May 23, 12
Increased complexity and decision making around when to run “jobs”
Wednesday, May 23, 12
Sounds like an app Wednesday, May 23, 12
models, views, controllers, jobs, client libs Wednesday, May 23, 12
models, views, controllers, jobs, client libs jobs, client libraries Wednesday,
May 23, 12
models, views, controllers jobs, client libraries Wednesday, May 23, 12
models, views, controllers jobs, client libraries Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue Wednesday, May
23, 12
models, views, controllers jobs, client libraries message queue Emits event
messages Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue m “User
123 linked twitter account with token ‘abc’” Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue m “User
123 linked twitter account with token ‘abc’” Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue m Consumes
messages, acts Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue m Consumes
messages, acts Wednesday, May 23, 12
models, views, controllers jobs, client libraries message queue m “Every
30 seconds, I’ll hit the twitter api with token ‘abc’ and then the feed engine api for user 123” Wednesday, May 23, 12
Wednesday, May 23, 12
pros: increased flexibility & control horizontal scaling smaller apps fewer
specs per app cons: burden of complexity on you Wednesday, May 23, 12