Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
resque-scheduler
Search
Fumiaki MATSUSHIMA
November 30, 2016
Programming
0
190
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
230
GraphQL Ruby benchmark
mtsmfm
1
860
タイムアウトにご用心 / Timeout might break application state
mtsmfm
6
2.6k
Build REST API with GraphQL Ruby
mtsmfm
0
360
GraphQL Ruby をちょっとだけ速くした / Make graphql-ruby faster a bit
mtsmfm
1
760
Gaming PC on GCP
mtsmfm
0
760
How to introduce GraphQL to an existing React-Redux application
mtsmfm
1
270
Canary release in StudySapuri
mtsmfm
0
3.2k
Other Decks in Programming
See All in Programming
AIコーディングエージェント(NotebookLM)
kondai24
0
190
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
340
【Streamlit x Snowflake】データ基盤からアプリ開発・AI活用まで、すべてをSnowflake内で実現
ayumu_yamaguchi
1
120
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.5k
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
6
2.2k
チームをチームにするEM
hitode909
0
330
認証・認可の基本を学ぼう後編
kouyuume
0
240
AIコーディングエージェント(skywork)
kondai24
0
170
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
730
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
440
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
100
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
We Have a Design System, Now What?
morganepeng
54
7.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
[SF Ruby Conf 2025] Rails X
palkan
0
520
Optimizing for Happiness
mojombo
379
70k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
BBQ
matthewcrist
89
9.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
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 機構難しい