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
とある業務オペレーション自動化の話
Search
onigra
October 09, 2015
Technology
0
950
とある業務オペレーション自動化の話
StackOverflow DevDays in Japan 2015.10.09
onigra
October 09, 2015
Tweet
Share
More Decks by onigra
See All by onigra
THE GOAL
onigra
3
60
devsumi-2024-summer
onigra
4
1.7k
第一種低層住居専用地域
onigra
0
230
jaws-ug-ecspresso-meetup-20230808
onigra
0
1.7k
ginza-ruby-kaigi-01
onigra
4
970
PHP-CS-FixerとかAtomとか
onigra
1
1.3k
プログラミング初心者でも始められるコミュニティへの参加と貢献
onigra
4
730
Techblog Deep Dive Meetup #1
onigra
0
1.8k
about tsudura
onigra
0
250
Other Decks in Technology
See All in Technology
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
150
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
390
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
170
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
0
170
TypeScript、上達の瞬間
sadnessojisan
46
13k
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
120
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.2k
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
180
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Invisible Side of Design
smashingmag
298
50k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Teambox: Starting and Learning
jrom
133
8.8k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Embracing the Ebb and Flow
colly
84
4.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Bash Introduction
62gerente
608
210k
Transcript
ͱ͋ΔۀΦϖϨʔγϣϯ ࣗಈԽͷ StackOverflow DevDays 2015.10.09 @onigra_
onigra Yudai Suzuki / ླ༤େ onigra_ tenso, inc. / tensoגࣜձࣾ
• Web Application Developer • DevOps • Rubyist • My
favorite episode of Joel on Software: My First BillG Review
tensoגࣜձࣾʹ͍ͭͯ
Cross Border E-Commerce ӽڥECαʔϏε
We buy at Japanese EC on your behalf and ship
the items to your address overseas.
Monolithic PHP Application
Monolithic PHP Application Micro Ruby Application Micro Ruby Application Micro
Ruby Application Micro Ruby Application
։ൃͷܦҢ
։ൃͷܦҢ • αʔϏε։࢝ॳʹ࡞ΒΕͨɺཧߪೖͰ ༻͞ΕΔγεςϜ͕͋ͬͨ • αʔϏε͕֦େ͠ɺ͕ࣗೖࣾͯ͠࡞Γ͢ ͜ͱʹͳͬͨ
Architecture
Application • Ruby (Ruby on Rails) • Capybara • PhantomJS
(Poltergeist) • Sidekiq
Infrastructure • AWS • Ansible • Tsudura (Original Packer Clone)
• Capistrano • Blue-Green Deployment
None
Blue-Green Deployment • Auto Scaling Groupʹର͢ΔELBͷ͚֎͕͠Ͱ͖ΔΑ͏ʹͳͬͨͷͰಋ ೖ • ௨ৗͷDeployCapistranoɺϛυϧΣΞͷΞοϓσʔτΛߦͬͨࡍ ʹBG
Deploy • PackerͰAnsible͕͍ͮΒ͔ͬͨΓɺLaunch Config࡞Auto Scaling GroupͷସΛࣗಈͰΓ͔ͨͬͨͷͰࣗ࡞ͷPacker clone cliΛ࡞ • http://github.com/onigra/tsudura • https://speakerdeck.com/onigra/about-tsudura
Job͕͍ͬͯΔ͜ͱ • νΣοΫΞτʹඞཁͳใΛࣗಈೖྗ • ෳͷ߲ͷத͔Βબͷஅ͕ඞཁͳͷ ɺͪ͜ΒͰܾΊͨ༏ઌॱҐΛͱʹબ͠ ͨΓ͢Δ • ࣗࣾཧը໘ʹऔಘͨ͠ใΛࣗಈೖྗ
SidekiqͰJobΛ ฒྻ࣮ߦ͢Δࡍʹ • δϣϒ͝ͱʹηογϣϯ͕͔ΕΔΑ͏ʹ͢Δ • ͚ͳ͍ͱಉ࣮࣌ߦ࣌ʹΤϥʔ • CookieϑΝΠϧΛRunnerͷΠϯελϯε͝ͱʹ TempfileͰ࡞ •
RunnerͷΠϯελϯε͝ͱʹCapybara::SessionΛ ࡞
class WorkerSession attr_reader :session def initialize tempfile = Tempfile.new(prefix, path)
Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new( app, phantomjs_options: [ "--cookies-file=#{tempfile.path}", ] ) end @session = Capybara::Session.new(:poltergeist) end end
class ExampleRunner def initialize(param) @param = param @capybara = WorkerSession.new
end def run login access_to_checkout select_shipping_method select_payment_method submit ensure logout delete_session end end
class ExampleWorker include Sidekiq::Worker sidekiq_options queue: :example def perform(param) ExampleRunner.new(param).run
end end
։ൃ։͔࢝ΒϦϦʔε·Ͱ
։ൃ։͔࢝ΒϦϦʔε·Ͱ • ։ൃ։͔࢝Β2ि͙ؒΒ͍ͰϦϦʔε • جຊ1ਓͰ։ൃɺΠϯϑϥɺӡ༻ • ϑΝʔετϦϦʔεҰ෦ػೳͷΈ • ϑΝʔετϦϦʔεޙɺগͣͭ͠ଞͷਓʹखͬͯΒͬͨΓ •
ܧଓతʹϦϦʔεΛߦ͍ɺ࠷ऴతʹۀଆ͕Γ͍ͨ͜ͱΛશ෦࣮ݱɻͦ ͷܭըΛͪΌΜͱۀ୲ऀͱѲͬͨ • CIͱσϓϩΠͷΈΛ͔ͬ͠Γඋͯͨ͠ͷͰɺҰਓͰ͏·͍ͬͨ͘
ӡ༻͕͡·ͬͯ
PhantomJS͕Ϋϥογϡ͢Δ
None
ϦϦʔεॳ • ࣮ߦ݅: 600-900/Day • ࣦഊ݅: 10-100/Day • PhantomJSͷΫϥογϡAuto HealingͰޡ
ຐԽͭͭ͠ӡ༻
৽ػೳϦϦʔε
৽ػೳϦϦʔεલ • ࣮ߦ݅: 1200-2000/day • ࣦഊ݅: 100-200/day
ϦϦʔεޙ • ࣮ߦ݅: 5000-6000/day • ࣦഊ݅: 600-1500/day • Ұ൪ଟ͍࣌Ͱ12000/5000
ϝϞϦϦʔΫʹΑΔCrashଟൃ • δϣϒ͕ϑϦʔζͨ͠ΠϯελϯεΛ௵ͯ͠ ཱͯΔӡ༻ͷʑ • ΠϯελϯεαΠζ্͛ͨΓɺΠϯελϯε ૿ͯ͠େ͖ͳޮՌແ͠
(❨›°□°)❩›︵ᵲᴸᵲ
֘ػೳͷ࠶ઃܭ • ແବʹ࣮ߦͯ͠͠·ͬͯΔδϣϒ͕ଟ͍ • ঢ়ଶΛݟͯɺແବͳδϣϒ࣮ߦ͞Εͳ͍Α ͏ʹͨ͠ • ݟͯݟ͵;Γͯͨ͠ϝϞϦϦʔΫʹຊ֨తʹ ͖߹͏
ϝϞϦϦʔΫରࡦ
https://github.com/teampoltergeist/ poltergeist#memory-leak PoltergeistͷREADME
session.driver.quit • ηογϣϯ࡞࣌ʹىಈͨ͠PhantomJSͷϓ ϩηεΛKILL͢Δϝιου͕༻ҙ͞Εͯͨ • ݁ہͬͨͷ͜ΕΛRunner#runϝιουͷ ensureʹೖΕ͚ͨͩ
None
None
None
class ExampleRunner def initialize(param) @param = param @capybara = WorkerSession.new
end def run login access_to_checkout select_shipping_method select_payment_method submit ensure logout delete_session end end ͜͜ବ
νϡʔχϯάͷ݁Ռ • ॲཧ݅: 5000-7000/day • ࣦഊ݅: 20-50/day • Ϋϥογϡൃੜ͠ͳ͘ͳͬͨ •
ϏϏͬͯಉ࣮࣌ߦΛগͳ͍͕ͯͨ͘͠ɺ૿ ͯ͠ͳ͘ͳͬͨ
None
ݱࡏ๊͍͑ͯΔ՝
CI͕͏·͍͔͘ͳ͘ͳͬͨ • CICircleCI • ถ͔ΒͷΞΫηεʹͳΔͷͰɺςετͰԿLogin܁ Γฦ͢ͱɺαʔϏεʹΑͬͯCaptureڬ·Εͯ٧Ή • ։ൃॳେৎͩͬͨʢςετέʔεগͳ͔͔ͬͨΒʁʣ • ࠃͷαʔόʹDrone.ioཱͯΔͱ͔ɺࠃͷCIαʔϏε
(SideCI)͏ͱ͔ݕ౼த
વ͕ͩɺ֎෦αʔϏεͷ ϚʔΫΞοϓ͕มΘͬͨΒେม • ͦΕΛݕ͢ΔͷΛؚΊͯɺ1ʹճςετ ࣮ߦͯͨ͠Μ͚ͩͲ… • ͱΓ͋͑ͣࣗͷϚγϯͰ1ʹԿճ͔࣮ߦ͠ ͯΔ • ࠓͷॴൃੜ͍ͯ͠ͳ͍
࠷ޙʹ
࠷ޙʹ • ͜Μͳײ͡ͰʑதͷαʔϏεΛεέʔ ϧͤ͞ΔͨΊʹؤு͍ͬͯ·͢ • ͦΜͳঢ়گͳͷͰɺฐࣾΤϯδχΞืूதͰ ͢ • ಛʹΠϯϑϥΤϯδχΞืूதͰ͢ʂ
Do you have any question?