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
Running App on AppRunner
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ohr486
June 27, 2021
Technology
880
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Running App on AppRunner
2021-06-27
Drecom SRE Sunday
https://drecom.connpass.com/event/213139/
ohr486
June 27, 2021
More Decks by ohr486
See All by ohr486
負荷試験Night#1 負荷試験2023年トレンド
ohr486
17
4.9k
Elixir/PhoenixによるWeb開発の現場から
ohr486
1
670
Hacking Phoenix Performance
ohr486
1
430
Plug & WAF
ohr486
2
570
elixirをプロダクションに導入する
ohr486
1
760
IEx maniacs
ohr486
4
700
Hack and Read Elixir
ohr486
2
830
sponsor-talk-drecom-heisei-ruby-kaigi
ohr486
0
920
ex-app-on-k8s
ohr486
0
280
Other Decks in Technology
See All in Technology
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
3
550
人間はどの意思決定を手放せるのか
kawasima
14
6.7k
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
1
1.3k
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
160
データ_AIの事業の勝敗をわけるもの
nek0128
0
350
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
4
1.7k
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
5
2.3k
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
3
2.9k
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
800
現場で役立つ技術負債の効果的な返済方法
masuda220
PRO
8
4k
品質と信頼性を地続きにする
grimoh
0
380
omasushiというライブラリを作った
polidog
PRO
0
230
Featured
See All Featured
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
How STYLIGHT went responsive
nonsquared
100
6.3k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
Marketing to machines
jonoalderson
1
5.8k
Designing for humans not robots
tammielis
254
26k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
740
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
520
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Chasing Engaging Ingredients in Design
codingconduct
0
310
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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の改善に期待しましょう