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
160
社内アプリで 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
340
Hermes Engineのチカラを その身で感ぜよう!
haochenx
0
220
Other Decks in Programming
See All in Programming
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
720
return文におけるstd::moveについて
onihusube
1
1.4k
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
410
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
140
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
230
快速入門可觀測性
blueswen
0
480
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
360
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
1.2k
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
1.2k
선언형 UI에서의 상태관리
l2hyunwoo
0
250
Androidアプリの One Experience リリース
nein37
0
740
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
200
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
171
50k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Documentation Writing (for coders)
carmenintech
67
4.5k
The Cult of Friendly URLs
andyhume
78
6.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Designing for humans not robots
tammielis
250
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
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! ͓ΘΓ