Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Twelve-Factor-Appから学ぶECS設計プラクティス/ECS practice...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
k-ozawa
April 24, 2025
Technology
320
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Twelve-Factor-Appから学ぶECS設計プラクティス/ECS practice for Twelve-Factor-App
k-ozawa
April 24, 2025
More Decks by k-ozawa
See All by k-ozawa
インフラ屋さんはAIコーディングエージェントとどう生きるか/How infrastructure engineers interact with Kiro
ozawa
2
370
コンソールで学ぶ!Cloud Runの機能とオプション/Learn about Cloud Run features and options through the console
ozawa
2
130
サーバシステムを無理なくコンテナ移行する際に伝えたい4つのポイント/Container_Happy_Migration_Method
ozawa
1
330
our_eks_to_ecs_migration_chronicle.pdf
ozawa
0
89
ECS × AWS Signer を使ったイメージ署名ワークフローを試してみた
ozawa
1
3.5k
コンソールで学ぶ!ECSの機能とオプション
ozawa
0
340
コンテナのCIについてインフラ目線で気にしておきたいこと
ozawa
0
150
Finchを触ってみて現状運用で使えそうか考えてみた
ozawa
0
480
Other Decks in Technology
See All in Technology
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
200
「今盗んで、後で解く」に備える ― AWSのポスト量子暗号入門
yama3133
2
260
TiDBファミリーにDWHが新登場!! TiDB最新情報 / TiDB update 202609
yoshiakiyamasaki
0
140
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
210
20260929_AmazonGuardDutyの検出通知メールにAWS DevOpsAgentの調査結果を追加する
yhana
1
320
エージェントはローカル、検証はMicroVM — Lambda MicroVMsでつくるServerless CI
fujioka6789
4
850
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
400
なぜAI任せのゲームは面白くならないのか?
hirohasuyoutube
0
220
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
220
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.8k
Harness Engineering on Rails
joelq
0
700
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
650
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
390
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Documentation Writing (for coders)
carmenintech
77
5.5k
Mobile First: as difficult as doing things right
swwweet
225
10k
Music & Morning Musume
bryan
48
7.4k
Ruling the World: When Life Gets Gamed
codingconduct
0
370
Chasing Engaging Ingredients in Design
codingconduct
0
340
How GitHub (no longer) Works
holman
316
150k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
540
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Transcript
Twelve-Factor Appから学ぶ ECS設計プラクティス 2025年04月24日 NRIネットコム株式会社 NTシステム事業二部 尾澤 公亮 NRIネットコム TECH
AND DESIGN STUDY #63
1 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 2012年にHerokuの中の人によって提唱された、
モダンアプリケーションを作り上げるための方法論 Twelve-Factor App とは ref: https://12factor.net/ja/
2 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy インフラメンにも大事な
Twelve Factor-App ↓アプリの話だけどインフラも知っておいた方が良い理由↓ タスク定義や構成で「なぜこうなっているのか」の意図が汲み取れない • なぜ環境変数にこの値が入っているのか • なぜこのコンテナが必要なのか • なぜDockerfileでこんなコマンドを実行しているのか • なぜECSを使うのか、etc... Twelve-Factor App とは
3 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy ◼インフラエンジニア、クラウドアーキテクト
◼AWS、コンテナを中心とした、 Webシステム設計/開発/運用/保守 ◼ex.: ECS, EKS, Codeシリーズ 尾澤 公亮(KOSUKE OZAWA)
4 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 構成要素
コードベース 依存関係 設定 バックエンドサービス ビルド、リリース、実行 プロセス ポートバインディング 並行性 廃棄容易性 開発/本番一致 ログをイベントストリーム として扱う 管理タスクは一回限りの プロセス
5 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy コードベース
バージョン管理されている1つのコードベースと複数のデプロイ GitHub Actions GitHub Amazon ECS Amazon ECS 本番 開発
6 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 依存関係を明示的に宣言し分離する
→Gemfile.lock、package.json、etc... OSパッケージに依存しない →alpineイメージにcurl入ってない問題 依存関係
7 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 設定
設定を環境変数に格納する Parameter Store Amazon ECS Key参照で 直接読み込み
8 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy バックエンドサービス
バックエンドサービスをアタッチされたリソースとして扱う direnv、compose.yml等で ローカル用変数を定義
9 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy ビルド、リリース、実行
ビルド、リリース、実行の3つのステージを厳密に分離する デプロイ アーティファクト 作成 BGデプロイ で必要
10 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy プロセス
アプリケーションを1つもしくは複数の ステートレスなプロセスとして実行する 疎結合
11 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy ポートバインディング
ポートバインディングを通してサービスを公開する Fargateはデフォルトでアプリのデフォルトポートをバインドする
12 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 並行性
プロセスモデルによってスケールアウトする Amazon ECS Amazon EKS AWS Application Auto Scaling
13 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 廃棄容易性
高速な起動とグレースフルシャットダウンで堅牢性を最大化する コンテナイメージの軽量化 Seekable OCI PID 1問題
14 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy コンテナイメージの軽量化
マルチステージビルド ビルドに必要な実行ファイルのみを 稼働用イメージにCOPY →アプリ起動に不要なファイルを含めない
15 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy コンテナイメージの軽量化
キャッシュ戦略 特定ディレクトリをキャッシュ指定 →差分が発生するライブラリのみ取得 する →処理時間の短縮にも BuildKit環境の整備が必要 実行環境によって手順が異なる
16 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy Seekable
OCI ref: https://aws.amazon.com/jp/blogs/news/under-the-hood-lazy-loading-container-images-with-seekable-oci-and-aws-fargate/ 実行に必要な処理箇所を特定し、 イメージの完全インストール前に起動する (Lazy Loading) → 起動時間の高速化
17 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy Seekable
OCI 実行に必要な処理箇所を特定し、 イメージの完全インストール前に起動する (Lazy Loading) → 起動時間の高速化 ref: https://aws.amazon.com/jp/blogs/news/under-the-hood-lazy-loading-container-images-with-seekable-oci-and-aws-fargate/ 現状SOCI snapshotter環境構築コストがかかる イメージサイズ 250MB以上推奨
18 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy PID
1 問題 ENTRYPOINT [“nginx”, “-g”, “daemon off;”] → PID 1:nginx master ENTRYPOINT [“/bin/sh”, “-c”, “’nginx -g daemon off;’”] → PID 1:/bin/sh ref: https://note.shiftinc.jp/n/ndc63c45d9f97?gs=b214340a89d1 実行モジュール(Nginx)が /bin/sh のサブコマンドとして実行される 実行モジュールからのSIGTERMを /bin/sh が受け取れず、一定時間(10秒)後にSIGKILL →停止に時間がかかる、正常に終了しない
19 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 開発/本番一致
開発、ステージング、本番環境をできるだけ一致させた状態を保つ 時間のギャップ 人材のギャップ ツールのギャップ ※Twelve Factor Appの文言から抜粋
20 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 開発/本番一致
開発、ステージング、本番環境をできるだけ一致させた状態を保つ
21 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 開発/本番一致
開発、ステージング、本番環境をできるだけ一致させた状態を保つ 管理環境が多すぎると全部の冪等性を担 保するのって結構難しい →ドリフト検知はしておいても良いかも しれない
22 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy ログをイベントストリームとして扱う
サーバ側でバッファリングしない
23 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy 管理タスクは1回限りのプロセス
DBマイグレーションはタスク化 踏み台、ECS Execの活用
24 Copyright(C) NRI Netcom, Ltd. All rights reserved. #nncstudy •
Adam Wiggins「THE TWELVE-FACTOR APP」 • https://12factor.net/ja/ • Amazon Web Servicesブログ「詳解 : Seekable OCI を使用した AWS Fargate におけるコンテナイメージの遅延読み込み」 • https://aws.amazon.com/jp/blogs/news/under-the-hood-lazy-loading-container-images-with-seekable-oci-and-aws-fargate/ • SHIFT技術ブログ「Docker上のサーバーを強制終了ではなく正常に終了する PID1になるプロセスとは?を理解してみた」 • https://note.shiftinc.jp/n/ndc63c45d9f97?gs=b214340a89d1 参考文献
None