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.2k
メンティー同士で輪読会を始めたら学びしかなかった
rvirus0817
1
1k
MENTAを5年やってみて:メンタリングで意識していること
rvirus0817
0
450
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
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
TypeScript、上達の瞬間
sadnessojisan
46
13k
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
フルカイテン株式会社 採用資料
fullkaiten
0
40k
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
360
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
0
980
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
270
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
330
Featured
See All Featured
RailsConf 2023
tenderlove
29
900
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Why Our Code Smells
bkeepers
PRO
334
57k
Raft: Consensus for Rubyists
vanstee
136
6.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
Principles of Awesome APIs and How to Build Them.
keavy
126
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)