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
ECS/Fargateの活用事例 (Ruby on Rails編)
Search
adachin0817
September 18, 2020
Technology
3
2.9k
ECS/Fargateの活用事例 (Ruby on Rails編)
【アソビュー×ランサーズ】AWSでのオーケストレーションツールの活用事例(EKS vs ECS)
https://lancersrecruit.connpass.com/event/187989/
adachin0817
September 18, 2020
Tweet
Share
More Decks by adachin0817
See All by adachin0817
入社1ヶ月でここまでやった!Findy Toolsインフラ支援の最適化
rvirus0817
11
7.3k
メンティー同士で輪読会を始めたら学びしかなかった
rvirus0817
1
1k
MENTAを5年やってみて:メンタリングで意識していること
rvirus0817
0
460
Lancersをコンテナへ本番移行する取り組み
rvirus0817
1
1.7k
~CircleCIでTerraformリリースのサーバーレス化~ インフラの独自リリースを継続的リリースへ
rvirus0817
0
3.6k
Terraform v0.12.29 → v1.0.5にバージョンアップする上で気をつけること
rvirus0817
0
4.1k
MENTAをAWSに移行して振り返る(ECS/Fargate + Laravel編)
rvirus0817
3
8.6k
ECS/Fargateの活用事例(CakePHP編)
rvirus0817
1
4k
Do u know DigitalOcean?
rvirus0817
1
2.1k
Other Decks in Technology
See All in Technology
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
180
The Rise of LLMOps
asei
9
1.7k
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
260
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
110
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
日経電子版のStoreKit2フルリニューアル
shimastripe
1
150
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
190
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
OS 標準のデザインシステムを超えて - より柔軟な Flutter テーマ管理 | FlutterKaigi 2024
ronnnnn
1
290
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Teambox: Starting and Learning
jrom
133
8.8k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
The Invisible Side of Design
smashingmag
298
50k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
For a Future-Friendly Web
brad_frost
175
9.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Code Review Best Practice
trishagee
64
17k
Transcript
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ECS/Fargateͷ׆༻ࣄྫ (Ruby on Railsฤ) ϥϯαʔζגࣜձࣾ SRE/҆ୡ
ྋ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ΞδΣϯμ ɾࣗݾհ ɾݱࡏऔΓΜͰ͍Δ͜ͱ ɾECS/FargateͷϝϦοτσϝϦοτ ɾ։ൃڥΛ࡞ΔϙΠϯτ
ɾStg/ຊ൪ڥͷߏʹ͍ͭͯ ɾSSH/࡞ۀ༻ίϯςφʮdevopsʯʹ͍ͭͯ ɾCircleCIʹΑΔίϯςφσϓϩΠ ɾECS Scheduled TasksʹΑΔόον࣮ʹ͍ͭͯ ɾϩά/ίϯςφࢹʹ͍ͭͯ ɾ·ͱΊ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ࣗݾհ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ࣗݾհ ɾ҆ୡ ྋ(adachin) ɾLancers SRE
2018~ ɾ@adachin0817 ɾRVIRUS0817 ɾblog.adachin.me ɾwiki.adachin.me ɾOSS : ɾCakePHPͰݸਓαʔϏε։ൃத
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ݱࡏऔΓΜͰ͍Δ͜ͱ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ݱࡏऔΓΜͰ͍Δ͜ͱ ɾڈळ ɾάϧʔϓձࣾ(γΫϩϚʔέςΟϯά) ɾ͘͞ΒͷΫϥυͰӡ༻ ɾॳΊͯECS/FargateʹҠߦνϟϨϯδ
ɾࠓ4݄ʹҠߦྃ ɹɾࠓճͪ͜ΒͷΛ͠·͢!! ɾݱࡏ(5݄͔Β) ɾάϧʔϓձࣾ(Lancers Agency)ɹ ɾECS/FargateͰҠߦத!!
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) EC2ͱൺֱͨ͠ECS/Fargate ͷϝϦοτσϝϦοτ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) EC2ͱൺֱͨ͠ECS/FargateͷϝϦοτσϝϦοτ ϝϦοτ ɾଐਓԽ͕ൃੜ͠ͳ͍ ɾImmutableͳαʔόʔͷӡ༻ ɹɾ҆ఆӡ༻ɺӡ༻ޮͷΞοϓ
ɾϗετΠϯελϯεͷཧ͕ল͚Δ ɾλεΫ୯ҐͰࣗ༝ʹϦιʔεมߋՄೳ ɾεέʔϧΞτͷ͢͠͞ σϝϦοτ ɾσόοά͕ͮ͠Β͍ ɾdocker execSSH͕Ͱ͖ͳ͍ ɾλεΫͷىಈ͕Ί ɹɾόον࣮ߦ͘ͳΔ ɾྉ͕͓ۚߴΊ ɹɾEC2ΑΓׂߴʢ1ׂʙ2ׂʣ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ։ൃڥΛ࡞Δ ϙΠϯτ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ։ൃڥΛ࡞ΔϙΠϯτ ɾຊ൪ڥͱಉͷߏΛ࠶ݱ ɾELB(H2O)ίϯςφ(ϦόʔεϓϩΩγ) ɾApp(ίϯςφ) ɹɾruby:2.5.7
ɹɾRails4.2.11 ɹɾNginx ɾMySQLίϯςφ ɹɾ5.7 ɾ֤ΞϓϦέʔγϣϯͷىಈSupervisorͰཧ ɾbundle installAppίϯςφͰϩάΠϯ࣌ʹ࣮ߦ ɹɾsupervisorctlͰΞϓϦΛrestart͢ΔΑ͏ʹ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) Stg/ຊ൪ڥͷ ߏʹ͍ͭͯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) Stg/ຊ൪ڥͷߏʹ͍ͭͯ ɾTerraformͰશϦιʔείʔυԽ ɾStgڥλεΫ1ͭ ɾdevopsίϯςφͷར༻ ɾDBRDS
AuroraʹҠߦ ɾը૾S3ʹอଘ ɾϩάCloudWatch Logs ɾόονECS Scheduled Tasks ɾ෦ࠪ(ϩάͷू) ɹɾAmazon Kinesis ɾσϓϩΠCircleCIͷΈͰ࣮ ɾࢹDatadog
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SSH/࡞ۀ༻ίϯςφ ʮdevopsʯʹ͍ͭͯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SSH/࡞ۀ༻ίϯςφʮdevopsʯʹ͍ͭͯ ɾAppʹSSH͠ͳ͍ ɾSSH/࡞ۀ༻ίϯςφ(Appͱಉ) ɹɾdevopsͱ໋໊ ɾίϚϯυͰRDSଓ
ɹɾdumprestore ɾaws cliͷར༻ ɾrails consoleͰͷσόοά ɾSSMͷSession Manager ͋Δ͕ ɹɾखܰʹ౿Έ͔ΒSSHΛ͍ͨͨ͠Ί ɾVPC PeeringͰϥϯαʔζͷωοτϫʔΫ͔ΒSSHϩάΠϯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) CircleCIʹΑΔ ίϯςφσϓϩΠʹ͍ͭͯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) CircleCIʹΑΔStg/ຊ൪σϓϩΠʹ͍ͭͯ(ॳظ) ɾCircleCIͷOrbs ɹɾDockerfileͷbuild ɹɾECRpush ɹɾECSϦϏδϣϯͷߋ৽
ɹɾαʔϏελεΫఆٛͷߋ৽ ɹɾDBϚΠάϨʔγϣϯ ɹɾrspec ɾgit flow ɾdevelopϒϥϯν ɹɾϚʔδ͢ΔͱStgʹϦϦʔε ɾmasterϒϥϯν ɹɾϚʔδ͢Δͱຊ൪ʹϦϦʔε
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) APIܦ༝ͰͷStgڥͷσϓϩΠ(ݱࡏ) ɾStgڥͷσϓϩΠ ɹɾgithub flow ɹɾγΣϧεΫϦϓτ
ɹɹɾҙͷϒϥϯνΛࢦఆ ɾૉૣ͘σϓϩΠ͕Մೳ ɹɾ։ൃޮ͕Ξοϓ ɾTerraform CIڥΛ࣮ $ sh deploy.sh ԼهͷΑ͏ʹϒϥϯνΛࢦఆ࣮ͯ͠ߦ͍ͯͩ͘͠͞ɻ (ྫ) sh deploy.sh ϒϥϯν໊ $ sh deploy.sh fix-nginx { "number" : 74, "state" : "pending", "id" : "xxxxxx-xxxxx-xxxxx-xxx-xxxxxxxx", "created_at" : "2020-08-27T06:14:43.973Z" } ϒϥϯν໊/ fix-nginx ͷStgσϓϩΠΛ։࢝͠·ͨ͠!
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) όονͷ࣮ʹ͍ͭͯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ECS Scheduled TasksʹΑΔόον࣮ʹ͍ͭͯ ɾࠓ·Ͱ ɹɾgem
whenever ɹɾschedule.rb ɾݱࡏ ɹɾECS Scheduled Tasks ɹɹɾCloudWatchͷΠϕϯτϧʔϧ ɹɹɾTerraformԽ { "containerOverrides": [ { "name": "HogeWorker", "command": ["bundle","exec","rails","runner","HogeWorker.new.execute"] } ] }
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ϩάʗίϯςφࢹ ʹ͍ͭͯ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ϩά/ίϯςφࢹʹ͍ͭͯ ɾΞΫηε/ΞϓϦϩάɺRDSࠪ/Τϥʔϩά ɹɾCloudWatch Logsʹ ɹɾࠓ·Ͱ
ɹɹɾLambdaͰS3ʹγϯΫɹɹ ɹɹɾPythonͰ࣮͍ͯͨͨ͠Ίӡ༻ίετΞοϓ ɹɾࠓճ ɹɹɾAmazon Kinesis Data FirehoseͰS3ʹू ɹɹɾTerraformԽ ɾࢹ ɹɾMackerel→DatadogʹҠߦ ɹɾλεΫఆٛʹdatadog-agentΛಈ࡞ͤ͞ΔΑ͏ʹ ɹɾcpu:10ɺmemory:256 TerraformԽ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ·ͱΊ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ·ͱΊ ɾγϯϓϧͳߏͰ࣮ݱͰ͖ͨ ɾখ͍͞αʔϏε͔ΒECS/FargateԽத ɾDockerΠϝʔδͱλεΫఆٛͰӡ༻Մೳ ɾॳΊͯίϯςφຊ൪ӡ༻͢Δʹ͔ͳΓϋϚΔ
ɹɾϔϧενΣοΫ͕௨Βͳ͍ͱίϯςφ͕མͪͨΓ ɹɾσϓϩΠͷ࣮͕େม ɹɾLinuxྗ͕ࢼ͞ΕΔ ɾࠓޙ ɹɾRuby2.7.1/Rails6ͷόʔδϣϯΞοϓ ɹɾίϯςφͷ੬ऑੑݕ (Trivy) ɹɾσϓϩΠ͕10͔͔ΔͷͰվળ ɹɾChatOpsͰͷϦϦʔε ɹɾDatadogͰϩά࿈ܞ ɹɾϥϯαʔζຊՈίϯςφҠߦʹνϟϨϯδ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SREٻΉʂʂ ECS/Fargate/PHPͰͷڥΛ͓͠·͢ʂ
2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS)