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チーム 挑戦と進化の軌跡
rvirus0817
3
750
入社1ヶ月でここまでやった!Findy Toolsインフラ支援の最適化
rvirus0817
11
7.9k
メンティー同士で輪読会を始めたら学びしかなかった
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.7k
ECS/Fargateの活用事例(CakePHP編)
rvirus0817
1
4.1k
ECS/Fargateの活用事例 (Ruby on Rails編)
rvirus0817
3
2.9k
Other Decks in Programming
See All in Programming
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
390
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
320
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
340
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
160
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
620
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
220
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
230
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
140
Flatt Security XSS Challenge 解答・解説
flatt_security
0
460
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
480
Recoilを剥がしている話
kirik
5
8.1k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
530
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Typedesign – Prime Four
hannesfritz
40
2.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
The Invisible Side of Design
smashingmag
299
50k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
A designer walks into a library…
pauljervisheath
205
24k
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