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
Cloudflare R2をトリガーにCloudflare Workersを動かしてみた
Search
KMiura
December 13, 2024
Technology
0
240
Cloudflare R2をトリガーにCloudflare Workersを動かしてみた
2024/12/13 Cloudflare Meetup Nagoya 第7回 2024年忘年LT大会
https://cfm-cts.connpass.com/event/334373/
KMiura
December 13, 2024
Tweet
Share
More Decks by KMiura
See All by KMiura
運用しているアプリケーションのDBのリプレイスをやってみた
miura55
1
1.1k
Amazon Rekognitionを使ったインターホンハック
miura55
0
98
Pythonでルンバをハックしてみた
miura55
0
190
あなたの知らないクラフトビールの世界
miura55
0
380
Storage Browser for Amazon S3を触ってみた + α
miura55
0
240
あのボタンでつながるSORACOM
miura55
0
150
Postman Flowsで作るAPI連携LINE Bot
miura55
0
400
Lambdaと共に歩んだAWS
miura55
3
880
Bedrock Knowledge baseを使って今年の上半期のニュースを聞いてみた(リベンジ編)
miura55
0
300
Other Decks in Technology
See All in Technology
AI との良い付き合い方を僕らは誰も知らない (WSS 2026 静岡版)
asei
1
260
AWSと生成AIで学ぶ!実行計画の読み解き方とSQLチューニングの実践
yakumo
2
320
Digitization部 紹介資料
sansan33
PRO
1
6.4k
Scrum Guide Expansion Pack が示す現代プロダクト開発への補完的視点
sonjin
0
520
AIと融ける人間の冒険
pujisi
0
110
「駆動」って言葉、なんかカッコイイ_Mitz
comucal
PRO
0
140
Everything As Code
yosuke_ai
0
500
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
330
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.2k
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
850
AI: The stuff that nobody shows you
jnunemaker
PRO
1
160
Node vs Deno vs Bun 〜推しランタイムを見つけよう〜
kamekyame
1
370
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
120
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Side Projects
sachag
455
43k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
KATA
mclloyd
PRO
33
15k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
690
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Are puppies a ranking factor?
jonoalderson
0
2.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
41
Transcript
Cloudflare R2をトリガーにCloudflare Workersを動かしてみた KMiura(@k_miura_io)
自己紹介 • 三浦 耕生(こうき) • Acallのバックエンドエンジニア • JAWS UG名古屋&神戸 運営
• 鯱.py運営 • Cloudflare Meetup Nagoya 運営 @k_miura_io koki.miura05
Cloudflare Builder Day2024のアップデート
Cloudflare QueuesがGA • 2022年にベータリリースされたCloudflare QueuesがGA • スループットと同時実行数の制限が上がることで、より大量のメッセージを高速にさばける ようになった https://blog.cloudflare.com/builder-day-2024-announcements/#queues-is-ga
ドキュメントを見ると…
というわけで課金!
R2のイベント通知がGA • 今年の4月にベータリリースされたR2のイベント通知がGA • R2のイベントをQueueに飛ばしてWorkerで非同期処理を実現できる • もはやS3もどき https://blog.cloudflare.com/builder-day-2024-announcements/#event- notifications-for-r2-is-now-ga
やってみた
MQ(Message Queueing) • MQはシステムで流れるメッセージを溜め込むためのキュー(Queues) • ProducerはメッセージをMQに送る(R2) • ConsumerはMQからメッセージを取り出す(Worker) MQ Producer
Consumer
Queueの設定 • 「wrangler queues create <Queue名>」と叩くだ けで作成される • Workerのwrangler.tomlにコマンド出力の中に あるConsumer側の設定をするだけでメッセー
ジを受け取ることができる
R2のイベント通知設定 • 「wrangler r2 bucket notification create <R2バケット名> --event-type <イベント
の種類> --queue <Queue名>」と叩くとイベント設定ができる • object-create:オブジェクトが新規追加されるか、更新されることで発火するイベント • object-delete:オブジェクトが削除されたことで発火するイベント
DEMO
まとめ • Wranglerを使うことで簡単にQueueのセットアップ、R2のイベント通知設 定が簡単にできた • イベントのパターンもS3よりシンプルだが、細かいフィルタリングは Worker側で実装することになりそう • 次はKVあたりでもイベント・ドリブンができると予想(というかリリースし てほしい)
今回の記事・ソースコード https://zenn.dev/kmiura55/articles/ cloudflare-r2-queue-worker https://github.com/Miura55/ cloudflare-r2-queue-sample
END