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.8k
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
9
3.1k
メンティー同士で輪読会を始めたら学びしかなかった
rvirus0817
1
950
MENTAを5年やってみて:メンタリングで意識していること
rvirus0817
0
420
Lancersをコンテナへ本番移行する取り組み
rvirus0817
1
1.7k
~CircleCIでTerraformリリースのサーバーレス化~ インフラの独自リリースを継続的リリースへ
rvirus0817
0
3.5k
Terraform v0.12.29 → v1.0.5にバージョンアップする上で気をつけること
rvirus0817
0
4.1k
MENTAをAWSに移行して振り返る(ECS/Fargate + Laravel編)
rvirus0817
3
8.4k
ECS/Fargateの活用事例(CakePHP編)
rvirus0817
1
4k
Do u know DigitalOcean?
rvirus0817
1
2k
Other Decks in Technology
See All in Technology
EitherT_with_Future
aoiroaoino
0
490
HolidayJp.jl を作りました
mrkn
0
110
手軽に始める? おうちサーバーのすゝめ
nyagasan
0
180
トレタO/X アーキテクチャ移行記 Next.js App Router化への道のり / TORETA TECH UPDATE 1
okunokentaro
2
570
Azure SQL Database Hyperscale HA レプリカの監視
sansantech
PRO
0
190
Oracle Database Backup Service:サービス概要のご紹介
oracle4engineer
PRO
0
4k
タイミーのBraze活用 ~PUSH通知を活用したレコメンド~
ozeshun
2
120
RAGHack: Kickoff and RAG 101
pamelafox
0
200
技術ブログや登壇資料を秒で作るコツ伝授します
minorun365
PRO
17
4.5k
「名前解決」から振り返るAmazon VPC
yuki_ink
0
320
#Zenoh 完全に理解した 〜組込み純情篇〜
takasehideki
1
450
AWS版GitHub?Amazon CodeCatalystの全体像をまとめてみた
oshanqq
1
3.2k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
47
2.7k
RailsConf 2023
tenderlove
26
790
ReactJS: Keep Simple. Everything can be a component!
pedronauck
662
120k
Six Lessons from altMBA
skipperchong
26
3.3k
Testing 201, or: Great Expectations
jmmastey
35
6.9k
5 minutes of I Can Smell Your CMS
philhawksworth
201
19k
Raft: Consensus for Rubyists
vanstee
135
6.5k
How To Stay Up To Date on Web Technology
chriscoyier
785
250k
The Language of Interfaces
destraynor
153
23k
Fashionably flexible responsive web design (full day workshop)
malarkey
400
65k
From Idea to $5000 a Month in 5 Months
shpigford
378
46k
How to Ace a Technical Interview
jacobian
275
23k
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)