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
rails + serverengineで お手軽daemon
Search
threetreeslight
October 02, 2015
Technology
0
120
rails + serverengineで お手軽daemon
threetreeslight
October 02, 2015
Tweet
Share
More Decks by threetreeslight
See All by threetreeslight
Bottleneck is You
threetreeslight
0
82
Japan Office Society オフィスはスタートアップの成長を助長するのか?阻害するのか?
threetreeslight
0
97
スタートアップは見極められたくない
threetreeslight
0
35
VPoEの責務とは
threetreeslight
0
58
CiecleCIでもくもく会を支える技術
threetreeslight
0
45
Ego vs higher self
threetreeslight
0
35
Performance Hack 101
threetreeslight
0
78
複数のスタートアップを 通して得た失敗と学び
threetreeslight
0
65
How to probe prometheus & grafana. What is helm
threetreeslight
0
29
Other Decks in Technology
See All in Technology
"とにかくやってみる"で始めるAWS Security Hub
maimyyym
2
100
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
230
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
120
Taming you application's environments
salaboy
0
200
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
640
Terraform Stacks入門 #HashiTalks
msato
0
360
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
560
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
1.4k
SSMRunbook作成の勘所_20241120
koichiotomo
3
170
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.6k
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
29
13k
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
A Modern Web Designer's Workflow
chriscoyier
693
190k
It's Worth the Effort
3n
183
27k
Agile that works and the tools we love
rasmusluckow
327
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Ruby is Unlike a Banana
tanoku
97
11k
Facilitating Awesome Meetings
lara
50
6.1k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Code Reviewing Like a Champion
maltzj
520
39k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Transcript
rails + serverengineͰ ͓खܰdaemon Akira Miki Repro Inc. shinjuku.rb #29@metaps
Sep 30, 2015
Akira Miki Repro @treetreeslight
None
ղੳ͔Βղܾ·ͰαΫοͱ
About job
ReproͰ͍ͬͯΔjob܈ serverengine sidekiq AWS lambda ࢹͯ͠ൃՐ੍ޚ͍ͨ͠ ฒྻΛ੍ݶ͍ͨ͠ ฒྻΛ੍ݶ͠ͳ͍ ΨϯΨϯॲཧ͍ͨ͠ 4ͳͲͷ"84πʔϧ܈
ͱγʔϜϨεͳ࿈ܞͯ͠ ΨγΨγॲཧ͍ͨ͠
ͲΜͳ͜ͱʹͬͯΔͷʁ serverengine sidekiq AWS lambda w ಈըͷม w ղੳσʔλΩϟογϡ w
ఆظܾࡁ w QVTI༧ͷࢹ w *O"QQରऀͷߋ৽ FUDʜ w ϝʔϧΛૹΔ w ղੳσʔλΛૹΔ w ৴σʔλͷ࡞ FUDʜ w 1VTIૹΔ FUDʜ
ͲΜͳ͜ͱʹͬͯΔͷʁ serverengine sidekiq AWS lambda w ಈըͷม w ղੳσʔλΩϟογϡ w
ఆظܾࡁ w QVTI༧ͷࢹ w *O"QQରऀͷߋ৽ FUDʜ w ϝʔϧΛૹΔ w ղੳσʔλΛૹΔ w ৴σʔλͷ࡞ FUDʜ w 1VTIૹΔ FUDʜ
બఆܦҢΛϓϩτλΠϓ࣌ͷ ʮஏ͔ͣ͠ʙʙʙ͍ʯ ࣦഊஊ౿·͑ͯ
ϓϩτλΠϓͩ͠ͱΓ͋͑ͣ cron Rake script SQS SDK ̍୯ҐͩΑ͒
͋ΕʁϝϞϦᷓΕͯͶʁ
ͦΓΌrailsrequireͯ͠rakeୟͱ ϝϞϦΊͬͪΌ৯͏ΑͶ!! ϓϩτλΠϓͱ͍͑ࡶ͗ͨ͢!!!
ϓϩτλΠϓͱ͍͑ ͪΐͬͱؾΛ͓͔ͬͯ͘ cron SQS SDK Server Ӆ͠URL
CPUΔ͖ͩͯ͠Δɾɾɾʁ
ffmpegͬͯݶք·Ͱ CPU͏͔ΒͶʂ ϓϩτλΠϓͱ͍͑ࡶ͗ͨ͢!!!
ͪΌΜͱ͢Δظ • railsͷmodelࢿ࢈Λ͍·Θ͠ • ffmpeg͕CPUΛ৯͍ਚ͘͢ͷͰฒྻ੍ݶͭͭ͠ • Rails requireͷϝϞϦͷΦʔόʔϔου࠷খݶʹ • ࣗલͰdaemonϥούʔॻ͍ͯྑ͍͚Ͳɺγάφ
ϧ੍ޚܥͱ͔ॻ͘ͷΊΜͲ͍ <- Ұ൪ίϨ
serverengine
serverengine ͍͢!!! SQS SDK serverengine long poling wΔ͜ͱʹ߹ΘͤͯXPSLFSௐͭͭ͠ wTVQFSWJTFSࢠͱ͍͏ૉఢߏ wϩά·ΘΓγάφϧʹΑΔϓϩηε੍ޚ·ͰόονϦ
ؾΛ͚ͭͨ͜ͱ
Exception def cycle invoke end def invoke( *arguments )
execute( *arguments ) rescue => error report_exception(error) end def execute( *arguments ) raise NotImplementedError end def report_exception(error) # logging, rollbar, newrelic ... end • handle͠ͳ͕Βࢭ·Βͣલਐ
Avoid memory leak • ʢrubyͷઃఆͰղܾͰ͖Δͱࢥ͏͚Ͳʣfragmentation͕ ཷ·ΔͷͰఆظతʹڧ੍GC class worker … def
run begin GC.stop cycle ensure GC.start end rescue Exception => error report_exception error end … end
Zombi process • long polingதʹdeployΛ࿈ଓ͢Δͱɺzombi͕Ͱ͖Δ serverengine serverengine.pid Kill Kill ̍ճ
2ճ start start pollingத serverengine.pid Override
Memory Usage • serverengineprocess modelͳͷͰɺrailsશ෦͚ͬͯ ΔͱϓϩηεϝϞϦΛ͍ͬͺ͍৯Δɻ worker worker server supervisor
͜Εࢹܥ͡Όͳ͍͠ sidekiqͰΑ͔ͬͨΜ͡Όʁ
Ͱͨ͠ serverengine sidekiq AWS lambda w ಈըͷม w ղੳσʔλΩϟογϡ w
ఆظܾࡁ w QVTI༧ͷࢹ w *O"QQͷλʔήοτߋ ৽ w ಈըͷม w ϝʔϧΛૹΔ w ղੳσʔλΛૹΔ w ৴σʔλͷ࡞ FUDʜ w 1VTIૹΔ FUDʜ
·ͱΊ • serverengine͏ͱdaemon͕α ΫοͱͰ͖Δ