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を プロダクト運用してみた体験談 @Cloudflar...
Search
Haochen Kotoi-Xie
April 15, 2024
Programming
0
200
社内アプリで 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
420
Hermes Engineのチカラを その身で感ぜよう!
haochenx
0
240
Other Decks in Programming
See All in Programming
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
230
既存デザインを変更せずにタップ領域を広げる方法
tahia910
1
240
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1k
Gleamという選択肢
comamoca
6
760
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
370
ドメインモデリングにおける抽象の役割、tagless-finalによるDSL構築、そして型安全な最適化
knih
11
2k
ReadMoreTextView
fornewid
1
470
エラーって何種類あるの?
kajitack
5
300
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
350
Create a website using Spatial Web
akkeylab
0
300
C++20 射影変換
faithandbrave
0
530
XP, Testing and ninja testing
m_seki
3
180
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
7
490
Rails Girls Zürich Keynote
gr2m
94
14k
Writing Fast Ruby
sferik
628
61k
Embracing the Ebb and Flow
colly
86
4.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Building an army of robots
kneath
306
45k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
670
Typedesign – Prime Four
hannesfritz
42
2.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Thoughts on Productivity
jonyablonski
69
4.7k
Side Projects
sachag
455
42k
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! ͓ΘΓ