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
960
とある業務オペレーション自動化の話
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
67
devsumi-2024-summer
onigra
4
1.9k
第一種低層住居専用地域
onigra
0
230
jaws-ug-ecspresso-meetup-20230808
onigra
0
1.7k
ginza-ruby-kaigi-01
onigra
4
980
PHP-CS-FixerとかAtomとか
onigra
1
1.3k
プログラミング初心者でも始められるコミュニティへの参加と貢献
onigra
4
740
Techblog Deep Dive Meetup #1
onigra
0
1.9k
about tsudura
onigra
0
250
Other Decks in Technology
See All in Technology
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
340
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
170
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
kargoの魅力について伝える
magisystem0408
0
210
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
460
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
460
生成AIのガバナンスの全体像と現実解
fnifni
1
190
20241220_S3 tablesの使い方を検証してみた
handy
4
580
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
250
Featured
See All Featured
Visualization
eitanlees
146
15k
Typedesign – Prime Four
hannesfritz
40
2.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
4 Signs Your Business is Dying
shpigford
181
21k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Six Lessons from altMBA
skipperchong
27
3.5k
Embracing the Ebb and Flow
colly
84
4.5k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
How GitHub (no longer) Works
holman
311
140k
We Have a Design System, Now What?
morganepeng
51
7.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
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?