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.8k
Lancersをコンテナへ本番移行する取り組み
https://lancersrecruit.connpass.com/event/248522/
adachin0817
June 29, 2022
Tweet
Share
More Decks by adachin0817
See All by adachin0817
横断SREの立ち上げと、AWSセキュリティへの取り組みの軌跡
rvirus0817
3
2.3k
ゼロから創る横断SREチーム ~挑戦と進化~
rvirus0817
3
920
入社1ヶ月でここまでやった!Findy Toolsインフラ支援の最適化
rvirus0817
11
8.1k
メンティー同士で輪読会を始めたら学びしかなかった
rvirus0817
1
1k
MENTAを5年やってみて:メンタリングで意識していること
rvirus0817
0
480
~CircleCIでTerraformリリースのサーバーレス化~ インフラの独自リリースを継続的リリースへ
rvirus0817
0
3.7k
Terraform v0.12.29 → v1.0.5にバージョンアップする上で気をつけること
rvirus0817
0
4.2k
MENTAをAWSに移行して振り返る(ECS/Fargate + Laravel編)
rvirus0817
3
8.8k
ECS/Fargateの活用事例(CakePHP編)
rvirus0817
1
4.1k
Other Decks in Programming
See All in Programming
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
560
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
130
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.5k
Оптимизируем производительность блока Казначейство
lamodatech
0
970
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
370
2025.01.17_Sansan × DMM.swift
riofujimon
2
610
最近のVS Codeで気になるニュース 2025/01
74th
1
220
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
250
良いユニットテストを書こう
mototakatsu
13
3.6k
Amazon Nova Reelの可能性
hideg
0
230
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
960
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
510
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
970
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Adopting Sorbet at Scale
ufuk
74
9.2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
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