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
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
260
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
160
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
510
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
180
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
110
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
190
アップデート紹介:AWS Data Transfer Terminal
stknohg
PRO
0
170
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
13k
Designing for Performance
lara
604
68k
BBQ
matthewcrist
85
9.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Being A Developer After 40
akosma
87
590k
Thoughts on Productivity
jonyablonski
67
4.4k
A Tale of Four Properties
chriscoyier
157
23k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
GitHub's CSS Performance
jonrohan
1030
460k
A designer walks into a library…
pauljervisheath
204
24k
Fireside Chat
paigeccino
34
3.1k
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?