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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ohr486
June 27, 2021
Technology
890
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
680
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
930
ex-app-on-k8s
ohr486
0
280
Other Decks in Technology
See All in Technology
KanaAI
shreyas1009
0
130
Meet AgentCore Identity Consent Portal
hironobuiga
2
140
Account Factory for Terraformによる 標準化されたアカウント発行の自動化
pensuke628
0
120
IR Today: Theory, Practice, and Agents
dtunkelang
0
270
プラットフォームを「作る」、 チームに「入り込む」
sansantech
PRO
0
400
【ゲームメーカーズスクランブル2026】『Shadowverse: Worlds Beyond』UIとアニメーションで実現する最高のユーザー体験を叶えるプロトタイピング
cygames
PRO
1
700
AWS FinOps Agent 結局何が得意なの?
siromi
0
220
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
270
高負荷プロダクション環境におけるAWS Lambdaのリアル 〜スケールとコストを左右する実行ライフサイクルの技術仕様〜
maimyyym
2
830
認知負荷を吸収し、プロダクトをまたぐPR Preview基盤の設計事例
taiki45
2
550
Confitura 2026
logico_jp
0
110
The seven pitfalls of AI (revised version)
ufried
0
130
Featured
See All Featured
Test your architecture with Archunit
thirion
2
2.4k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
440
Crafting Experiences
bethany
1
360
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
560
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
Navigating Team Friction
lara
192
16k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
500
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
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の改善に期待しましょう