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
Running App on AppRunner
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ohr486
June 27, 2021
Technology
0
830
Running App on AppRunner
2021-06-27
Drecom SRE Sunday
https://drecom.connpass.com/event/213139/
ohr486
June 27, 2021
Tweet
Share
More Decks by ohr486
See All by ohr486
負荷試験Night#1 負荷試験2023年トレンド
ohr486
17
4.8k
Elixir/PhoenixによるWeb開発の現場から
ohr486
1
600
Hacking Phoenix Performance
ohr486
1
380
Plug & WAF
ohr486
2
530
elixirをプロダクションに導入する
ohr486
1
700
IEx maniacs
ohr486
4
630
Hack and Read Elixir
ohr486
2
770
sponsor-talk-drecom-heisei-ruby-kaigi
ohr486
0
870
ex-app-on-k8s
ohr486
0
250
Other Decks in Technology
See All in Technology
toCプロダクトにおけるAI機能開発のしくじりと学び / ai-product-failures-and-learnings
rince
6
5k
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
450
エンジニアとマネジメントの距離/Engineering and Management
ikuodanaka
3
700
DatabricksホストモデルでAIコーディング環境を構築する
databricksjapan
0
220
SREの仕事を自動化する際にやっておきたい5つのポイント
jacopen
6
1.2k
システムのアラート調査をサポートするAI Agentの紹介/Introduction to an AI Agent for System Alert Investigation
taddy_919
2
1.3k
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
1
400
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
5
1.7k
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
120
KubeCon + CloudNativeCon NA ‘25 Recap, Extensibility: Gateway API / NRI
ladicle
0
160
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
1
690
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
820
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Designing Powerful Visuals for Engaging Learning
tmiket
0
210
Information Architects: The Missing Link in Design Systems
soysaucechin
0
750
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
67
Transcript
Running App on AppRunner 2021-06-27 Drecom SRE Sunday slide:https://docs.google.com/presentation/d/1LpzbfhtwIhHo6t4lzhboy75L6Vj5LYpdlbPwvmmW5ek/edit?usp=sharing demo:https://github.com/ohr486/blog-sample-aws-app-runner
agenda • About Me • Target • Goal • AppRunnerとは
• AppRunnerのアーキテクチャ • Set Up AppRunner • Demo • AppRunnerでできること • AppRunnerでできないこと • AppRunnerに足りないもの • まとめ
About Me • Tsunenori Ohara/おーはら ◦ Twitter: @ohrdev ◦ Github:
ohr486 • Work ◦ Drecom, SRE部 manager ◦ SRE/Infra/Ruby,Elixir,Lisp,etc • Community ◦ tokyo.ex, ElixirConfJapan, Erlang&ElixirFest ◦ Japan Elixir Association ◦ meguro.rb, meguro.es, etc • Hobby ◦ 仏像制作, 丸太収集, 写経, 寺社仏閣 ◦ 人工衛星/アマチュア無線 ◦ 自転車/ダイエット/脂肪燃焼
Target • AWSでサービスを運用したい人 • EC2ではなくコンテナでサービスを運用したい人 • 簡単にサービスをセットアップしたい人 • Kubernetesの学習に挫折した人 •
モチベーション ◦ 運用サービス/システムが多すぎで管理がしんどい ◦ アプリはコンテナで運用したい ◦ ECS/EKSは便利だけどセットアップ・メンテする為に必要な知識が多すぎる ◦ ぱっとセットアップできて、いい感じにマネージしてくれるマネージドサービスが出たぞ
Goal • AppRunnerについて以下を理解する 1. AppRunnerの構成/アーキテクチャ 2. AppRunnerでできること・できないこと 3. AppRunnerで運用する際に気をつけること
AppRunnerとは • AWSのコンピューティング系の新サービス ◦ ソースコードのリポジトリ or コンテナイメージから Webアプリを簡単にデプロイ ◦ ネットワーク・ロードバランサー・
TLS証明書等の関連リソースを一括でセットアップ ◦ 同時リクエスト数に応じてオートスケールされる ◦ 簡単に一時停止&再開可能 ◦ サービスの実行分のみコスト請求される • 今(2021/6)のところソースコードからデプロイする場合のランタイムはPython3、 nodejs12のみ対応 ◦ これ以外のランタイムを利用したい場合は Dockerのコンテナレジストリからデプロイする必要があ る • 実際に動かして確認したい人はWORKSHOPがおすすめ ◦ https://www.apprunnerworkshop.com/
AppRunnerのアーキテクチャ user AppRunner ECR or initial & monitor code /
image AppRunner Service deploy web console API AWS CLI AWS SDK operation AppRunnerサービスのVPC LoadBalancer TLS証明書 AutoScaling container container container ・・・ Custom Domain CloudWatch logs github connection
Set Up AppRunner • GitHubのソースコードからdeployする場合 ◦ WORKSHOP参照(今回のプレゼンでは割愛します ) • コンテナイメージからdeployする場合
◦ アプリを作成 ◦ ECRにリポジトリを作成 ◦ AppRunnerサービスの作成 ◦ Dockerイメージの作成 ◦ ECRのリポジトリにイメージを push ◦ (必要に応じて)カスタムドメインの登録
Demo • AWSの事前準備 ◦ ECRリポジトリ ◦ RDS(Aurora/MySQL) ※ publicアクセス可能にしておく ◦
IAMロール • ソースコード ◦ aws: https://github.com/ohr486/blog-sample-aws-app-runner/tree/master/aws ◦ app: https://github.com/ohr486/blog-sample-aws-app-runner/tree/master/app • アプリ仕様 ◦ https://github.com/ohr486/blog-sample-aws-app-runner/blob/master/app/app/controllers/info_c ontroller.rb ◦ /info/cpu => アプリが動作するサーバー /コンテナのCPU情報を出力 ▪ cat /proc/cpuinfo ◦ /info/mem => アプリが動作するサーバー /コンテナのメモリ情報を出力 ▪ cat /proc/meminfo
App概要(1) container expose 8080 (HTTP) rails puma MySQL driver entrypoint.sh
= DB Migration = = Railsの起動 = expose 3306 (MySQL)
App概要(1) • Dockerfile ◦ https://github.com/ohr486/blog-sample-aws-app-runner/blob/master/app/Dockerfile.apprunne1 • entrypoint.sh ◦ https://github.com/ohr486/blog-sample-aws-app-runner/blob/master/app/ep.apprunner1.sh •
puma.rb ◦ https://github.com/ohr486/blog-sample-aws-app-runner/blob/master/app/config/puma1.rb
AppRunnerでできること • 負荷分散(ロードバランシング) • HTTPS通信(証明書発行) • オートスケーリング • 自動Deploy
AppRunnerでできないこと • バッチ・タスクスケジューラー ◦ RailsでいうところのSidekiqの様な非同期処理 • FireWall (WAF) • WebSocket通信
• コンテナへ内のプロセスへのAttach/Exec(REPL) • Webサーバー ◦ nginx/apacheの様な大量のコネクションの処理機構 • ログ転送(サイドカー) • apprunner-roadmap ◦ https://github.com/aws/apprunner-roadmap/issues
App概要(2) webサーバーを追加 container expose 8080 (HTTP) /app/tmp/sockets/puma.sock nginx listen 8080;
upstream sock rails puma bind unix domain sock MySQL driver entrypoint.sh = DB Migration = = Railsの起動 = = nginxの起動 = expose 3306 (MySQL) proxy
App概要(3) ログコレクタを追加 container expose 8080 (HTTP) /app/tmp/sockets/puma.sock nginx listen 8080;
upstream sock rails puma bind unix domain sock MySQL driver entrypoint.sh = fluentdの起動 = = DB Migration = = Railsの起動 = = nginxの起動 = expose 3306 (MySQL) logs fluentd expose 24224 (fluentd)
AppRunnerに足りないもの • WebAppの運用上困るもの/こと ◦ 選択できるCPU/Memoryのバリエーション(1vCPU/2vCPU, 2GB/3GB/4GB)が少ない ◦ Dockerイメージ(Dockerfile)が複雑になる(ベストプラクティスから逸脱する ) ▪
https://cloud.google.com/architecture/best-practices-for-building-containers?hl=ja ◦ Dockerで複数のプロセスを起動するので何かしらのプロセス管理の機構が必要 ▪ https://matsuand.github.io/docs.docker.jp.onthefly/config/containers/multi-service_contai ner/ ◦ Blue/Green Deploy・カナリアリリースの仕組み ▪ AWSの既存サービス(Route53 etc)を組み合わせてがんばればなんとかなるけど、煩雑にな る • セキュリティ上困るもの/こと ◦ AppRunnerからPrivateなSubnetへのアクセスができない
App概要(4) ネットワーク AWSのネットワーク AppRunnerサービスのVPC LoadBalancer AutoScaling container 運用アカウントのネットワーク 運用サービスのVPC publicなsubnet
privateなsubnet 通信できない 通信可能 RDS ElastiCache internet RDS ElastiCache Aurora Serverless 仕様上privateな subnetにDBを配 置できない DBはprivateな subnetに配置し たいができない
まとめ • AppRunnerの概要について紹介しました • ソース/Dockerイメージから簡単にWebAppに必要なリソース一式をdeployできる 事を開設しました • ただし今(2021/6)時点では本番運用に足りない機能・仕組みが散見します ◦ FireWall,
ログ転送, バッチ, WebSocket, etc ◦ Privateなネットワークへのアクセス ◦ マシンspec(vCPU/Mem)のバリエーション ◦ etc • AWSの改善に期待しましょう