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
EC2 で運用していた定期実行のバッチ処理を AWS Batch + EventBridge にした
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuta Dammatsu
November 19, 2021
64
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
EC2 で運用していた定期実行のバッチ処理を AWS Batch + EventBridge にした
趣味で開発しているアプリのバッチ処理を EC2 → AWS Batch + EventBridge にした話です。
Yuta Dammatsu
November 19, 2021
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Technical Leadership for Architectural Decision Making
baasie
3
570
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
450
Game over? The fight for quality and originality in the time of robots
wayneb77
1
280
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
Transcript
EC2 で運用していた定期実行のバッチ処理を AWS Batch + EventBridge にした
今回は自分が趣味で運用しているWebアプリの話 • どんなバッチ処理をしていたか → 対象サイトを10分ごとに Selenium でスクレイピング
従来のバッチ処理 • EC2 1台で実行 • 環境構築はSSHして必要なものを手動インストール → chromedriver とか入れるのがめんどくさい... •
スケジューリングは whenever という gem を使用 → crontab を使っているのとそこまで変わらずめんどくさい...
課題 • 環境構築するのがとても大変 • 各ジョブのモニタリングやログの出力ができていなかった • デプロイしたり、バッチ処理の設定を変更するのも面倒 • EC2をずっと動かすとお金がかかる →
約2000円/月
どうしていきたいか • 環境構築するのがとても大変 → Docker で環境構築したい。 • 各ジョブのモニタリングやログの出力ができていない → 管理画面で状況を見たい
& ログの設定もよしなにしたい • デプロイしたり、バッチ処理の設定を変更するのも面倒 → サーバーにSSHして設定するのはしたくない • EC2をずっと動かすとお金がかかる → バッチ処理時だけ動かしたい
None
AWS Batch とは
AWS Batch の概念 1. コンピューティング環境 → VPC, サブネットなどの設定 2. ジョブキュー
→ ジョブを管理するキュー 3. ジョブ定義🌟 → ECRのイメージの設定やメモリCPUの設定 4. ジョブ → ジョブ定義より生成される。
ジョブ定義について
好きな名前をつける 自分はとりあえず Fargate にし てみた。 これだけかかると明らかにおか しいみたいな秒数をつけておくと いいと思う。 リトライの回数を指定できる。
ECRのURIを設定 実行したいコマンドを書く。 Dockerfile の CMD に設定して いればそれでも良い。 ネットワークのアクセスが必要な らチェック メモリとCPUは任意で
その他の設定を開くと、 環境変数設定やログの設定が できる。 作成をクリック
AWS Batch 単体では定期実行はできない。 → キックするものが必要。
None
Amazon Event Bridge とは
名前と説明は好きなものを 定期実行なのでスケジューリン グを選択。 cron 式で記入。 (自動で実行時間のスケジュー ルが出てくれる。地味にありがた い。)
ターゲットは バッチジョブのキューを選ぶ ジョブキューとジョブ定義の ARN を記入。AWS Batchの画面を確 認する。 (選択肢にしてほしい) ジョブ名は好きなものをつける。
あとは作成を押すだけ。
ダッシュボード(各ジョブの詳細も見れる)
ログ(aws/batch/job 以下にログが流れてくる。)
まとめ • ECS のタスク定義みたいな感じでジョブ定義ができて便利。 • 各ジョブの状態もダッシュボードで見やすい。 • Event Bridge と組み合わせるとスケジューリングできる。
• 料金が2000円→300円に。