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
resque-scheduler
Search
Fumiaki MATSUSHIMA
November 30, 2016
Programming
0
180
resque-scheduler
Shinjuku.rb #43 発表資料
https://shinjukurb.connpass.com/event/44524/
Fumiaki MATSUSHIMA
November 30, 2016
Tweet
Share
More Decks by Fumiaki MATSUSHIMA
See All by Fumiaki MATSUSHIMA
Learning from performance improvements on GraphQL Ruby
mtsmfm
1
1.2k
Ruby で作る Ruby (物理)
mtsmfm
1
220
GraphQL Ruby benchmark
mtsmfm
1
840
タイムアウトにご用心 / Timeout might break application state
mtsmfm
6
2.6k
Build REST API with GraphQL Ruby
mtsmfm
0
330
GraphQL Ruby をちょっとだけ速くした / Make graphql-ruby faster a bit
mtsmfm
1
740
Gaming PC on GCP
mtsmfm
0
740
How to introduce GraphQL to an existing React-Redux application
mtsmfm
1
260
Canary release in StudySapuri
mtsmfm
0
3.1k
Other Decks in Programming
See All in Programming
KessokuでDIでもgoroutineを活用する / Go Connect #6
mazrean
0
110
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
200
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
180
20250808_AIAgent勉強会_ClaudeCodeデータ分析の実運用〜競馬を題材に回収率100%の先を目指すメソッドとは〜
kkakeru
0
200
実践 Dev Containers × Claude Code
touyu
1
240
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
130
TDD 実践ミニトーク
contour_gara
0
130
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
2
2.3k
オープンセミナー2025@広島LT技術ブログを続けるには
satoshi256kbyte
0
120
大規模FlutterプロジェクトのCI実行時間を約8割削減した話
teamlab
PRO
0
490
技術的負債で信頼性が限界だったWordPress運用をShifterで完全復活させた話
rvirus0817
1
2k
Honoアップデート 2025年夏
yusukebe
1
840
Featured
See All Featured
Six Lessons from altMBA
skipperchong
28
4k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
We Have a Design System, Now What?
morganepeng
53
7.7k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Embracing the Ebb and Flow
colly
87
4.8k
A designer walks into a library…
pauljervisheath
207
24k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
(株)永和システムマネジメント @mtsmfm 松島 史秋 resque-scheduler
松島 史秋 GitHub, Twitter @mtsmfm
ポケモン S/M まっちまー フレコ 1907-9185-9222
None
resque- scheduler
https://github.com/resque/resque-scheduler
大きく2つの 機能
- Delay - Schedule
- Delay - 10分後に実行 - Schedule - cron
resque 単体だと できない
ActiveJob
http://edgeguides.rubyonrails.org/active_job_basics.html#enqueue-the-job
ActiveJob が やってくれたり してないかな
Emoji provided free by Emoji One
https://github.com/mtsmfm/ resque-scheduler-example
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque- scheduler.rb#L4
挙動が違う
https://github.com/jmettraux/rufus-scheduler/blob/master/lib/rufus- scheduler.rb
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/tasks.rb#L17-L18
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/cli.rb#L117
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L59-L70
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/locking.rb#L65-L67
Lock
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/locking.rb#L3-L50
- master プロセスが落ちたときに複数回 enqueue されないための機構 - Redis の SETNX を使っている
- Delayed job は SETNX で単純な十分 - Scheduled job (cron っぽい方) は頻繁に master が変わると、マシンの時間がずれて いる場合に厳しい - (デフォルトだと) 3 分ごとに lock をとる - 2 回走ってもいいときや時間の同期がきっち りされているなら短くするとよい
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L59-L70
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L181-L190
Schedule job は?
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/locking.rb#L3-L50
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler/locking.rb#L28-L30
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L49-L53
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L89-L104
https://github.com/resque/resque-scheduler/blob/v4.3.0/lib/resque/ scheduler.rb#L124-L163
学び
- 概要のわかる ドキュメント大事 - resque-scheduler は 多重実行されるくらいなら job が失われた方がいいという方 針
- Lock 機構難しい