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
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
2
220
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
180
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
350
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
300
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
860
いざ、BSC討伐の旅
nikinusu
2
780
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
570
TypeScript、上達の瞬間
sadnessojisan
46
13k
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
Featured
See All Featured
Designing for humans not robots
tammielis
250
25k
What's in a price? How to price your products and services
michaelherold
243
12k
The Pragmatic Product Professional
lauravandoore
31
6.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Designing Experiences People Love
moore
138
23k
Faster Mobile Websites
deanohume
305
30k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Unsuck your backbone
ammeep
668
57k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Gamification - CAS2011
davidbonilla
80
5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
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?