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
rails + serverengineで お手軽daemon
Search
threetreeslight
October 02, 2015
Technology
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
rails + serverengineで お手軽daemon
threetreeslight
October 02, 2015
Transcript
26 slides
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͕α ΫοͱͰ͖Δ
More Decks by threetreeslight
See All by threetreeslight
実録 採用一投入魂
threetreeslight
0
57
Bottleneck is You
threetreeslight
0
140
Japan Office Society オフィスはスタートアップの成長を助長するのか?阻害するのか?
threetreeslight
0
140
スタートアップは見極められたくない
threetreeslight
0
66
VPoEの責務とは
threetreeslight
0
110
CiecleCIでもくもく会を支える技術
threetreeslight
0
72
Ego vs higher self
threetreeslight
0
55
Performance Hack 101
threetreeslight
0
130
複数のスタートアップを 通して得た失敗と学び
threetreeslight
0
100
Other Decks in Technology
See All in Technology
内製アプリとClaudeスキルのセキュリティチェック、 Backlogの課題で回しています。
ayaka_egaaa
0
200
Datadog の権限統制 〜Org 統合に向けて調べた注意点 / JDDUG-Meetup_24
visional_engineering_and_design
1
150
変更差分を読むために環境を整備しよう
pipepasta
1
340
属人化したISMS運用をGitHubとAIで仕組み化した1年間の記録
sioncojp
4
2.6k
Where Should Platform Complexity Live? Lessons from a Cross-Team PR Preview Platform
taiki45
0
110
AWS Emulator を評価する: 手元で動く AWS の API の仕組み、始め方、確かめ方
inariku
PRO
1
650
ぼくのClaude Codeの使い方
falken
PRO
5
7.2k
DevOps Agentにあらゆるセキュリティインシデントのトリアージを任せた件
jirtosterone
1
150
Kiro CLI 入門 (ターミナルと CI で使う) | 目指せ Kiro マスター 03
inariku
PRO
2
150
AI時代における医療情報システムのセキュリティ / Security of Healthcare IT Systems in the AI Era
henryofficial
0
170
ラクスル会社紹介資料|エンジニア向け / RAKSUL Introduction for Engineers
raksulrecruiting
0
110
An Introduction to Context Ontology Accelerator (teaching AI agents what your data means)
inariku
PRO
1
270
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Evolving SEO for Evolving Search Engines
ryanjones
0
360
Joys of Absence: A Defence of Solitary Play
codingconduct
1
580
A Modern Web Designer's Workflow
chriscoyier
699
190k
Designing for humans not robots
tammielis
254
26k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Color Theory Basics | Prateek | Gurzu
gurzu
1
520
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
300
Are puppies a ranking factor?
jonoalderson
2
4.2k
Ruling the World: When Life Gets Gamed
codingconduct
0
440