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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ohr486
June 27, 2021
Technology
870
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
660
Hacking Phoenix Performance
ohr486
1
420
Plug & WAF
ohr486
2
560
elixirをプロダクションに導入する
ohr486
1
750
IEx maniacs
ohr486
4
690
Hack and Read Elixir
ohr486
2
820
sponsor-talk-drecom-heisei-ruby-kaigi
ohr486
0
910
ex-app-on-k8s
ohr486
0
270
Other Decks in Technology
See All in Technology
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
280
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
240
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
280
PLATEAU で バーチャル花火大会
tatsuya1970
0
160
その“隠したつもり”が命取り ── 自前と平文をやめて「正解」に委ねる
kuroneko13
0
130
【CEDEC2026】『ウマ娘 プリティーダービー』 英語版のキャラクターの方言や口調をローカライズするための創造的アプローチ
cygames
PRO
2
1.1k
20分でわかるセキュアAPI
nwiizo
2
300
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
250
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
280
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
Genie Codeハンズオン応用編
taka_aki
0
110
ハーレムエンジニアリング
kazuma777777
0
180
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
New Earth Scene 8
popppiees
3
2.5k
Are puppies a ranking factor?
jonoalderson
1
3.8k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
370
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
340
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
670
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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の改善に期待しましょう