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
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
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
240
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
670
バグを直したら useEffect が消えた
colorful12
3
780
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
1.2k
Deep dive into the select statement (GopherCon UK)
jespino
0
160
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
120
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.3k
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
750
Press start. Python's next generation.
willingc
PRO
3
290
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
110
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
19k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Code Review Best Practice
trishagee
74
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
How GitHub (no longer) Works
holman
316
150k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
640
What's in a price? How to price your products and services
michaelherold
247
13k
Marketing to machines
jonoalderson
1
5.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
The SEO Collaboration Effect
kristinabergwall1
1
540
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
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
͓͠·͍