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
Lancersをコンテナへ本番移行する取り組み
Search
adachin0817
June 29, 2022
Programming
1
1.7k
Lancersをコンテナへ本番移行する取り組み
https://lancersrecruit.connpass.com/event/248522/
adachin0817
June 29, 2022
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
~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
ECS/Fargateの活用事例 (Ruby on Rails編)
rvirus0817
3
2.8k
Do u know DigitalOcean?
rvirus0817
1
2k
Other Decks in Programming
See All in Programming
Appleの新しいプライバシー要件対応: ノーコードアプリ プラットフォームの実践事例
nao_randd
1
450
dRuby 入門者によるあなたの身近にあるdRuby 入門
makicamel
4
340
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
180
New Order in Cascade Sorting Order
mugi_uno
3
2.5k
数値を文字列に整形する際の落とし穴とその解決策(iOSDC2024 ルーキーズLT) / iOSDC Japan 2024 Formatting Floating-Point Numbers
glassfiber
0
250
ドメイン駆動設計を実践するために必要なもの
bikisuke
3
290
【TID2024】模擬講義:プログラマと一緒にゲームをデザインしてみよう!
akatsukigames_tech
0
380
iOSDC 2024 SMBファイル共有をSwiftで実装する
kishikawakatsumi
1
110
Prompt Cachingは本当に効果的なのか検証してみた.pdf
ttnyt8701
0
260
RAGの回答精度評価用のQAデータセットを生成AIに作らせた話
kurahara
0
210
初めてのiOS関連GitHub ActionsをMarketplaceに公開するまでの実録
konifar
3
200
快適な開発と高セキュリティを実現するCryptoKitを活用したCoreDataのデータ暗号化術
grandbig
1
300
Featured
See All Featured
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
109
6.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
A Tale of Four Properties
chriscoyier
155
22k
Designing for Performance
lara
604
68k
The Invisible Customer
myddelton
119
13k
How GitHub Uses GitHub to Build GitHub
holman
472
290k
KATA
mclloyd
27
13k
Designing for humans not robots
tammielis
248
25k
Typedesign – Prime Four
hannesfritz
38
2.3k
Principles of Awesome APIs and How to Build Them.
keavy
125
16k
Debugging Ruby Performance
tmm1
72
12k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
58k
Transcript
ϥϯαʔζגࣜձࣾ ϓϩμΫτ։ൃ෦/ٕज़ج൫ SRE ҆ୡ ྋ ʲLancers x dipʳEngineer Meetup #1
LancersΛίϯςφຊ൪Ҡߦ͢ΔऔΓΈ
ࣗݾհ • ҆ୡ ྋ(adachin) • Lancers/SRE 2018/5~ • @adachin0817
• RVIRUS0817 • blog.adachin.me • wiki.adachin.me • ݸਓαʔϏε։ൃத(ਐḿѱ) ʲLancers x dipʳEngineer Meetup #1
ࠓճ͓͍ͨ͜͠ͱ • 2018ͷγεςϜ • TerraformԽਪਐ • Amazon Linux2Խ • ϩάαʔόʔͷഇࢭ
• ։ൃڥͷվળ • ϑϩϯτΤϯυͷվળ • چ։ൃڥɺEC2Ͱͷӡ༻՝ • Batch/AppΛίϯςφ • ࣗલσϓϩΠγεςϜΛഇࢭ • ෛՙରࡦͱϨεϙϯε • ·ͱΊ ʲLancers x dipʳEngineer Meetup #1
ฐࣾʹ͍ͭͯ ʲLancers x dipʳEngineer Meetup #1
άϧʔϓձࣾECS/FargateʹҠߦࡁΈ ʲLancers x dipʳEngineer Meetup #1
Ҏલొஃ͍ͯͨ͠εϥΠυͪ͜Β ʲLancers x dipʳEngineer Meetup #1
ʲLancers x dipʳEngineer Meetup #1
2018ϥϯαʔζͷαʔόʔߏ ʲLancers x dipʳEngineer Meetup #1
2021ϥϯαʔζͷαʔόʔߏ ʲLancers x dipʳEngineer Meetup #1
2021/10~(࣮ࢪ) ʲLancers x dipʳEngineer Meetup #1
TerraformԽ ʲLancers x dipʳEngineer Meetup #1
Ұ෦TerraformԽΛ͍ͯ͠Δ͕શͰͳ͍ • άϧʔϓձࣾશͯTerraformԽ • ຊՈҰ෦͔͠TerraformԽ͞Ε͍ͯͳ͍ ɾηΩϡϦςΟʔάϧʔϓIDͳͲΛͦͷ··ࢦఆ ɾEC2ͰͷߏஙಠࣗͷAWS CLIͰࣗಈԽ
ɾͦΕҎ֎खಈͰઃఆ • શͯΛterraform importΛ͢Δʹݫ͍͠ ɾϑΣʔζ͝ͱʹऔΓΉ͜ͱʹ ʲLancers x dipʳEngineer Meetup #1
Terraform Phase 1 • VPC ɾαϒωοτ ɾϧʔτςʔϒϧ
ɾΠϯλʔωοτήʔτΣΠ ɾNatήʔτΣΠ ɾΤϯυϙΠϯτ ɾηΩϡϦςΟάϧʔϓ • ELB ɾλʔήοτάϧʔϓ ɾϦεφʔϧʔϧ ʲLancers x dipʳEngineer Meetup #1 • EC2 • RDS • ACM • εςʔδϯάͱຊ൪ڥ߹Θͤͯ ɾ1ϲ݄ ɾͦΕҎ֎ࠓظରԠ
Terraform ։ൃڥͱCI/CD ʲLancers x dipʳEngineer Meetup #1
Amazon Linux 2Խ ʲLancers x dipʳEngineer Meetup #1
EC2ΛAmazon Linux 2Խ • Amazon Linux1Ͱӡ༻ ɾAppɺཧը໘(Admin)ɺBatchαʔόʔ ɾ20206݄3ʹηΩϡϦςΟΞοϓσʔτͷఏڙ͕ऴྃ
• άϧʔϓձࣾͷҠߦ͕ॏͳΓରԠͰ͖ͣ • ͞ΒʹArm͕ରԠ͞ΕͯύϑΥʔϚϯε্͕ঢͱίετݮ • άϧʔϓձࣾͷίϯςφͷϊϋ͕ߴ·ΓҠߦΛܾҙ ɾಉ࣌ʹMySQL8ԽऔΓΉ͜ͱʹ ʲLancers x dipʳEngineer Meetup #1
ϩάαʔόʔͷഇࢭ ʲLancers x dipʳEngineer Meetup #1
ϩάαʔόʔ͕୯Ұো • ੳج൫(Digdag/Embulk/BigQuery/Redash)Λӡ༻ ɾϩάج൫(Fluentd) ɾApp(ΞΫηεϩά/ΞϓϦέʔγϣϯϩά) ɹɾS3ʹू •
ਖ਼ৗʹಈ࡞͍ͯ͠ͳ͍ঢ়ଶ͕ʑݟड͚ΒΕ ɾϒϥοΫϘοΫεԽͱͷ՝ʹ… • td-agentͷόʔδϣϯΞοϓΛࢼΈ͕ͨ ɾ͏·͍͔͓ͣ͘ख্͛ঢ়ଶ ʲLancers x dipʳEngineer Meetup #1
Amazon KinesisʹҠߦ • CloudWatch Logs(awslogs)Λ࠾༻ ɾ։ൃϝϯόʔͰௐࠪͰ͖ΔΑ͏ʹ ɾൺֱతֶशίετ͕͍awslogsΛબ •
ϩάϙϦγʔΛݟ͢ ɾΞΫηεϩάS3ʹूͷ·· ɾΞϓϦϩάੳ༻్ͱͯ͠ར༻͠ͳ͍ • Datadog LogsͰKinesisͷ࿈ܞ ɾΞϓϦνʔϜॠ࣌ʹରԠՄೳ ɾՄ؍ଌੑΛߴΊΒΕΔΑ͏ʹ • ίϯςφʹҠߦ͢Δ४උ͕ͬͨ ʲLancers x dipʳEngineer Meetup #1
։ൃڥͷमਖ਼ ʲLancers x dipʳEngineer Meetup #1
։ൃڥͷमਖ਼ • ։ൃڥຊ൪ಉΛ࠶ݱ ɾAnsibleίϯςφ ɹɾύοέʔδΠϯετʔϧ • มߋ
ɾDocker Imageamazonlinux2 ɾsupervisorͰϓϩηεཧ ɾෆཁͳύοέʔδΛચ͍ग़͠আ ɾamazon-linux-extrasʹΑΔPHPΠϯετʔϧ ɾtd-agentͷআͱawslogsͷΠϯετʔϧ • ཧը໘ECS/FargateʹҠߦ͢ΔͨΊ ɾDocker fi leΛҰ͔Βbuild͢ΔΑ͏ʹ ʲLancers x dipʳEngineer Meetup #1
2022/03~(Ҡߦ) ʲLancers x dipʳEngineer Meetup #1
Ҡߦ͢Δʹ͋ͨͬͯ • ཧը໘(Admin)ECS/FargateʹҠߦ ɾCakePHP2EC2 ɾCakePHP4ECS/FargateͰಈ࡞ • BatchArmʹҠߦ •
AppArmʹҠߦͰ͖ͣintelͰӡ༻ ɾDatadog ɹɾdd-trace-php͕ArmΛαϙʔτ❌ ʲLancers x dipʳEngineer Meetup #1
ʲLancers x dipʳEngineer Meetup #1
͜͜Ͱٙʹࢥ͏ํ ͍ΔͷͰ ʲLancers x dipʳEngineer Meetup #1
Appίϯςφʹ Ҡߦ͠ͳ͍ͷ͔ʁ ʲLancers x dipʳEngineer Meetup #1
ϑϩϯτΤϯυͷ ՝ ʲLancers x dipʳEngineer Meetup #1
ϑϩϯτΤϯυͷωοΫͱվળ • ιʔείʔυ͕5GBҎ্ ɾyarn installͰ30Ҏ্͔͔Δ ɾίϯςφσϓϩΠͰ͕࣌ؒେʹ͔͔Δ • ϑϩϯτΤϯυΛׂ͔ͯ͠ΒҠߦ
ɾιʔεߏ্ɺύεʹΑΔॲཧׂ͕ࠔͰ͕͔͔Δ • ༧ΊϩʔΧϧͰϏϧυͯ͠ੜ͞ΕͨϑΝΠϧΛGitཧ͢Δӡ༻ ɾyarn installෆཁʹͳΓɺCI͕࣌ؒେ෯ʹॖ ɾAppαʔόʔͷίϯςφҠߦͰ͖Δ͕݅ͬͨ ʲLancers x dipʳEngineer Meetup #1
2022/04(࣮ࢪ) ʲLancers x dipʳEngineer Meetup #1
چ։ൃڥɺEC2Ͱͷ ӡ༻՝ ʲLancers x dipʳEngineer Meetup #1
SREͷӡ༻՝ • AnsibleίϯςφʹΑΔ։ൃڥͷ౷ҰʹΑΓ͕͔͔Δ ɾAppίϯςφΛECRͰڞ༻͢Δඞཁ͕͋Δ ɾύοέʔδͷߋ৽ͳͲίϯςφΛ࡞Γͯ͠ECRʹpush • Φʔτεέʔϧͷ࠶ઃఆͰAppαʔόʔΛ࡞Γ͞ͳ͚ΕͳΒͳ͍
ɾAMIΛखಈͰ࡞Γ͢ͱ͍͏τΠϧ͕ͬͨ·· • ࣗલͷσϓϩΠγεςϜ͕ଐਓԽ ɾෆ۩߹ͷରԠʹ͕͔͔Δ ʲLancers x dipʳEngineer Meetup #1
։ൃڥͷվળ ʲLancers x dipʳEngineer Meetup #1
৽։ൃڥ • Docker fi leʹΑΔҰൠతͳӡ༻ • ผϦϙδτϦ(playbook) ɾLancersຊମͷϦϙδτϦʹ౷Ұ •
Ansibleίϯςφഇࢭ • ϩάج൫Ͱར༻ ɾEC2ͱಉ༷awslogsΛΠϯετʔϧ ʲLancers x dipʳEngineer Meetup #1
BatchΛίϯςφ ʲLancers x dipʳEngineer Meetup #1
BatchαʔόʔECS Scheduled TaskʹҠߦ • όον100ݸҎ্ ɾԽͤͣEC2 1ͷΈͰӡ༻ ɾαʔόʔμϯAZো͕ى͖Δͱ
ɹɾαʔϏεʹӨڹ͕ग़ͯ͠·͏ঢ়گ • CakePHP4 ɾ80ݸͷΈҠߦ ɾ։ൃϝϯόʔ͕TerraformͰཧͰ͖ΔΑ͏ʹ • CloudWatch LogsɺSNSɺLambdaͰΤϥʔ௨ • CakePHP2ͷόονQAνʔϜ͕Ҡߦத ʲLancers x dipʳEngineer Meetup #1
ࣗલσϓϩΠγεςϜ ʹ͍ͭͯ ʲLancers x dipʳEngineer Meetup #1
ʮDeploy-Sanʯ • 2015~ ɾRuby on RailsͱJenkins ɾಠࣗγΣϧͰrsync •
Φʔτεέʔϧ࣌ ɾDeploy-san͔Β࠷৽ͷίʔυΛऔಘ ɾ୯Ұো • ϦϦʔε࣌ؒ ɾࠩߋ৽Ͱ1Ҏ ʲLancers x dipʳEngineer Meetup #1
CircleCIʹҠߦ ʲLancers x dipʳEngineer Meetup #1
CI/CDΛCircleCIʹҠߦ • MasterϚʔδ:ຊ൪ APIܦ༝:εςʔδϯά/ΧφϦΞ • ίϯςφσϓϩΠߴԽ ɾ.dockerignoreʹΑΔෆཁͳϑΝΠϧল͘
ɾDocker fi leͰෆཁͳύοέʔδͷ୨Է͠ ɾCircleCIͷcheckout_shallowΛར༻ ɹɾ࠷ޙͷίϛοτͷΈcheckout ɾremote-docker-layer-cachingΛ༗ޮԽ • 5Ҏ·ͰॖΊΔ͜ͱ͕Ͱ͖ͨ ʲLancers x dipʳEngineer Meetup #1
ΧφϦΞڥͷσϓϩΠΛ੍ݶ • ຊ൪DBΛࢀর ɾΧφϦΞڥʹ୭ͰϦϦʔεͰ͖ͯ͠·͏ • CircleCI ɾcontext
ɹɾSecurity Group ɹɾGitHub Teamsͷݖݶ͋ΔਓͷΈঝೝ • https://wiki.adachin.me/archives/1313/ ʲLancers x dipʳEngineer Meetup #1
ෛՙରࡦͱϨεϙϯε ʲLancers x dipʳEngineer Meetup #1
ෛՙରࡦ • EC2࣌ ɾc5ܥΠϯελϯε ɾECSͩͱCPUબͰ͖ͳ͍ • Fargate Spot
ɾطଘͷ3Fargate ɾΦʔτεέʔϧFargate Spot(ίετݮ) • Φʔτεέʔϧ ɾ࠷খͰ3ɺ࠷େͰ20 ɾCPU 20%Ͱ૿Ճ 10%Ͱݮগ • php-fpmνϡʔχϯάͨ͠͠ ʲLancers x dipʳEngineer Meetup #1
2022/06(Ҡߦ) ʲLancers x dipʳEngineer Meetup #1
ʲLancers x dipʳEngineer Meetup #1
ҠߦޙͷϨεϙϯεʹ͍ͭͯ • ϥϯαʔζதʹෛՙ͕ϐʔΫ • αʔόʔϨεϙϯεेmsఔ • ݱࡏ ɾCPU 60%Ͱ૿Ճ
40%Ͱݮগ ɾΦʔτεέʔϧ7 ʲLancers x dipʳEngineer Meetup #1
Ҡߦޙͷίετ ʲLancers x dipʳEngineer Meetup #1
·ͱΊ ʲLancers x dipʳEngineer Meetup #1
·ͱΊ • 1ͰΓ͖Δ͜ͱ͕Ͱ͖ͨ ɾάϧʔϓձࣾͰͷϊϋΛ׆͔ͤͨ • ੜ࢈ੑ্͕ظ ɾSREͷτΠϧݮ
ɾ։ൃ෦શମͷϦϦʔεϑϩʔվળ • ࠓޙ ɾϑϩϯτΤϯυͷϞμϯԽ ɾPHP8.1/CakePHPͷόʔδϣϯΞοϓ ʲLancers x dipʳEngineer Meetup #1
ΤϯδχΞϒϩάॻ͍ͯ·͢ ʲLancers x dipʳEngineer Meetup #1
͝ਗ਼ௌ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ ʲLancers x dipʳEngineer Meetup #1