Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Redisでバッチ処理を冗長化しつつ排他制御
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ryonext
September 17, 2014
Programming
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Redisでバッチ処理を冗長化しつつ排他制御
ryonext
September 17, 2014
More Decks by ryonext
See All by ryonext
AWS Lambda の Ruby 対応
ryonext
0
280
TwitterのList編集しやすいやつ作った
ryonext
0
1.8k
validationについて
ryonext
1
860
AWS Lambda と API GatewayでRails使わずに済んだ話
ryonext
8
4.4k
capistrano-bundle_rsync使ったらオートスケールが高速化した話
ryonext
8
2.6k
PumaとUnicornで最近自分が理解したこと
ryonext
13
9.6k
Hubot事例
ryonext
1
1.7k
CircleCIとwercker
ryonext
3
1.3k
rubykaigi 3day interactive white board
ryonext
2
410
Other Decks in Programming
See All in Programming
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.9k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
150
Agents on Rails - Rails at Scale 2026
irinanazarova
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
Intent as Code
shoppingjaws
6
1.1k
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
150
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
510
What We Talk About When We Talk About XP
m_seki
2
660
すこし踏み込む CancellationToken
htkym
2
680
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
430
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
300
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
HDC tutorial
michielstock
2
880
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
710
How to Ace a Technical Interview
jacobian
281
24k
Mind Mapping
helmedeiros
1
370
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
How to Talk to Developers About Accessibility
jct
2
550
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Transcript
3FEJTͰόονॲཧΛ Խͭͭ͠ഉଞ੍ޚ
ࣗݾհ
͜͏͍͏ύλʔϯ ͓Εͷ3BJMT"QQ ֎෦ͷ"1* 6TFS
ຖճ"1*ϦΫΤετ͢Δͱ w ԠతʹͭΒ͍ w "1*αʔόʹෛՙ͕͔͔Δ
͜͏͍͏෩ʹ͢Δ ͓Εͷ3BJMT"QQ ֎෦ͷ"1* 6TFS ϢʔβʔϦΫΤετ όονॲཧ
3BJMTͳΒ w XIFOFWFS DBQJTUSBOPͰBQQαʔόʹσϓϩ ΠͷλΠϛϯάͰDSPO࡞Ͱ͖ͯḿΔ
㵺㱿㵺 ɻP ͯΑʁ"QQαʔόͬͯԽ͞ΕͯΔΑͳʁ
c"QQ "QQcᵎ ☋ʆ ᵊࡾ
◠㷩◠ ☛Ͳͬͪʹొ͓͍ͯͨ͠Αʔ # Begin Whenever generated tasks for: oreno_app PATH=/var/www/oreno_app/shared/bundle/ruby/2.1.0/bin:/usr/local/rbenv/
versions/2.1.2/bin:/usr/local/rbenv/libexec:/usr/local/sbin:/usr/local/ bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games ! 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /var/www/ oreno_app/releases/20140917060508 && RAILS_ENV=production bundle exec rake kankore:ensei --silent >> log/crontab.log 2>&1' ! # End Whenever generated tasks for: oreno_app
‧▓▒░ `Т` ░▒▓‧͏Θ͋͋͋͋͋͋
ՕॴͰΔͱ w ࢿݯͷແବݣ͍ײ w Կ͔ΛΠϯΫϦϝϯτ͢ΔͳͲɺͭͬͨΒக ໋తͳॲཧͩͱࢮ͵
͜ΕͰղܾʂʁ ͓Εͷ3BJMT"QQ ͓Εͷ3BJMT"QQ όον࣮ߦαʔό
͍͕ͭ͜མͪͨΒࢮ͵ όον࣮ߦαʔό ʀŋAТŋ
ͦ͜Ͱ3FEJT task nanika: :environment do sleep(rand(5)) # 実行時間をずらす redis =
Redis.new unless redis.get(‘task_executed') redis.setex('task_executed', 300, Time.now) # やりたいタスクを書く end end
͜͏͢Δ͜ͱͰ w ઌʹಈ͍ͨํ3FEJTʹΩʔ͕ͳ͚ΕΩʔΛ ࡞ͬͯλεΫ࣮ߦ w Ωʔ͕͋ͬͨΒଈ࠲ʹΊΔ w ΩʔҰఆ࣌ؒͰʢ࣍ͷDSPO࣮ߦ·Ͱʹʣফ͑ Δ w
ͭ·ΓɺԽͭͭ͠ഉଞ੍ޚͰ͖Δ
ͱ͍͏͜ͱΛͬͯ͘ΕΔ(FN ͕͋Γ·ͨ͠ w IUUQTHJUIVCDPNLFOOSFEJTNVUFY
͜͏͍͏ײ͡Ͱॻ͚·͢ Redis::Classy.db = Redis.new() mutex = Redis::Mutex.new('lock_access', expire: 180) begin
mutex.lock! # やりたい処理を書く rescue Redis::Mutex::LockError puts 'locked' end
͓͠·͍