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
55
devsumi-2024-summer
onigra
4
1.6k
第一種低層住居専用地域
onigra
0
220
jaws-ug-ecspresso-meetup-20230808
onigra
0
1.6k
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
240
Other Decks in Technology
See All in Technology
10分でわかるfreee エンジニア向け会社説明資料
freee
18
520k
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
210
AWSコンテナ本出版から3年経った今、もし改めて執筆し直すなら / If I revise our container book
iselegant
15
4k
Datachain会社紹介資料(2024年11月) / Company Deck
datachain
3
16k
30万人が利用するチャットをFirebase Realtime DatabaseからActionCableへ移行する方法
ryosk7
5
350
大規模データ基盤チームのオンプレTiDB運用への挑戦 / dpu-tidb
cyberagentdevelopers
PRO
1
110
一休.comレストランにおけるRustの活用
kymmt90
3
580
AWS re:Inventを徹底的に楽しむためのTips / Tips for thoroughly enjoying AWS re:Invent
yuj1osm
1
570
Forget efficiency – Become more productive without the stress
ufried
0
140
生成AIと知識グラフの相互利用に基づく文書解析
koujikozaki
1
140
AWS CodePipelineでコンテナアプリをデプロイした際に、古いイメージを自動で削除する
smt7174
1
100
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.4k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Ruby is Unlike a Banana
tanoku
96
11k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Being A Developer After 40
akosma
86
590k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Navigating Team Friction
lara
183
14k
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?