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 D1を プロダクト運用してみた体験談 @Cloudflare Meetup Nagoya
Search
Haochen Kotoi-Xie
April 15, 2024
Programming
0
79
社内アプリで Cloudflare D1を プロダクト運用してみた体験談 @Cloudflare Meetup Nagoya
Haochen Kotoi-Xie
April 15, 2024
Tweet
Share
More Decks by Haochen Kotoi-Xie
See All by Haochen Kotoi-Xie
社内アプリで Cloudflare D1を プロダクト運用してみた体験談(Tokyo)
haochenx
0
150
Hermes Engineのチカラを その身で感ぜよう!
haochenx
0
160
Other Decks in Programming
See All in Programming
“Seeing Like a Programmer”—Resiliency, Limits, and Moral Hazards in Software Engineering (LambdaConf 2024)
chriskrycho
0
430
ペパボOpenTelemetry革命
pyama86
2
980
戦略的DDDは重いのか? / Is strategic DDD heavy?
pictiny
3
2.1k
チーム立ち上げにAWSを活用したらClaudeさんに褒められた話
mkdev10
3
230
ts-morphを使ってコードリプレイスとASTへのハードルを下げる!
nyawach
5
330
Three ways to use AI on Android: The Good, the Bad and the Ugly
marxallski
0
120
Productivity is Messing Around and Having Fun
hollycummins
1
180
TypeScript 関数型スタイルでバックエンド開発のリアル
naoya
49
16k
Docker_OSS_ホスティング入門
satokoki645
0
140
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
13
4.3k
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
510
Jetpack Composeとデザインシステム
rmakiyama
0
230
Featured
See All Featured
Fireside Chat
paigeccino
22
2.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
41
4.5k
Typedesign – Prime Four
hannesfritz
36
2.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
Building Applications with DynamoDB
mza
88
5.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1.1k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
7k
How to train your dragon (web standard)
notwaldorf
75
5.2k
For a Future-Friendly Web
brad_frost
172
9k
Web development in the modern age
philhawksworth
203
10k
Transcript
Haochen Kotoi-Xie on 2024-04-12 (bd15w5) ࣾΞϓϦͰ Cloudflare D1Λ ϓϩμΫτӡ༻ͯ͠Έͨମݧஊ @Cloudflare
Meetup Nagoya @ฐࣾ
Cloudflare D1ͬͯΈͨ ࠷ۙ GA ʹͳͬͨ
+ 㱺 Cloudflare D1 ͬ͘͟Γ D1
㱺 Cloudflare D1 Region = Global! ΦϨϯδ৭ͷ SQLite! ͬ͘͟Γ D1
+
ެࣜʹΑΔͱ? Cloudflare D1 ग़య: https://www.cloudflare.com/developer-platform/d1/
ฐࣾ homepage: kxc.inc • Target: ʮଧࠁγεςϜʯ • Status: ϓϩμΫγϣϯӡ༻ •
Tech Stack: Workers + D1 • Complexity: ͍ • Total Satisfaction: ·͊·͊ • Code Matuality: ࡶ • Code Performance: ͱͯΑ͍ D1 ͬͯΈͨ
ฐࣾ homepage: kxc.inc • Target: ʮଧࠁγεςϜʯ • Status: ϓϩμΫγϣϯӡ༻ •
Tech Stack: Workers + D1 • Complexity: ͍ • Total Satisfaction: ·͊·͊ • Code Matuality: ࡶ • Code Performance: ͱͯΑ͍ ར༻Πϝʔδ D1 ͬͯΈͨ
D1 ͬͯΈͨ • Target: ʮଧࠁγεςϜʯ • Status: ϓϩμΫγϣϯӡ༻ • Tech
Stack: Workers + D1 • Code Matuality: Ұ࠷దԽͯ͠ͳ͍ • Complexity: ͍ • System Performance: ͱͯΑ͍ • Total Satisfaction: ·͊·͊ ฐࣾ homepage: kxc.inc
ར༻Πϝʔδʢଧࠁʣ Request Journey 1. Cmd: ʮpunch ...ʯ 2. HTTP POST
㱺 api1.kxc.inc/worklogger/v0/punching 3. Cloudflare Workers (api1.kxc.inc)㱺 Cloudflare D1 db = context.env.D1_WORKLOGGER st = db.prepare(`...sql..(?, ?, ?1)..`) .bind(param1, param2) await db.exec(st) D1 ͬͯΈͨ
ײ • ͱʹ͔͍͍͘͢ (Workers ͔Βͩͱ) • ૣ͍! ͍҆! • 㱺
listing ͷࡶίʔυͰ CPU Time ~30ms • ~2,000ߦ૯ͳΊ + JSσʔλ͝ʹΐ͝ʹΐ, etc • latency 2ܻmsɺମײͰແࢹͰ͖ΔϨϕϧ ར༻Πϝʔδʢlistingʣ D1 ͬͯΈͨ
Usage Stat ײ • ͱʹ͔͍͍͘͢ (Workers ͔Βͩͱ) • ૣ͍! ͍҆!
• 㱺 listing ͷࡶίʔυͰ CPU Time ~30ms • ~2,000ߦ૯ͳΊ + JSσʔλ͝ʹΐ͝ʹΐ, etc • latency 2ܻmsɺମײͰແࢹͰ͖ΔϨϕϧ • 1 >5k Request ͰແྉʹͳΔݟࠐΈ (Paid Workers) • ࠷େ 1 DB 10GB ·ͰΒ͍͠ • Transaction ͳ͍ͷ͕ਏ͍.. (SQLite ͳͷͰɺ stored function ͳ͍..) • Batch ͞Εͨͷ 1 txn Ͱ͕͢.. D1 ͬͯΈͨ
• 1DB 10GB ·Ͱ! (ࠓ·Ͱ 100MB → 1GB) • λΠϜτϥϕϧ!
• σʔλ Export / Import ※ͳΜͱࠓ·ͰͰ͖ͳ͔ͬͨ :D • άϩʔόϧɾϨϓϦΧ • Account͝ͱ: 50,000 DB! (max storage = 250GB) ※ιϑτϦϛοτΒ͍͠ • ແྉͰ࢝ΊΒΕΔ! • ແྉ: 10DB, 500MB/DB, 5GB/Account, 5M read /day, 100K write /day ࠷ۙ GA (General Available) ʹͳͬͨΒ͍͠ Cloudflare D1
Cloudflare D1 ݁ (Txn ΄͍͚͠Ͳ..) D1 ͍͍ͧ!
Cloudflare D1 Region = Global! ΦϨϯδ৭ͷ SQLite! ͓ΘΓ