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
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
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
230
App Intentsのビルドプロセスを支える技術
kntkymt
0
400
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
300
新卒PdEのリアル
ryu1013
1
510
スマート反転とウェブアクセシビリティ
camiha
0
210
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
2.1k
Are APIs Still Relevant in the AI Era?
soyuka
0
270
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
310
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
590
すこし踏み込む CancellationToken
htkym
2
600
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.8k
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
Balancing Empowerment & Direction
lara
6
1.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Navigating Weather and Climate Data
rabernat
0
520
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
500
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
530
Crafting Experiences
bethany
1
350
The untapped power of vector embeddings
frankvandijk
2
1.9k
The Limits of Empathy - UXLibs8
cassininazir
1
680
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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
͓͠·͍