Build serverless app trên Cloudflare Build a serverless app on Cloudflare
Bạn muốn deploy app nhanh mà không cần quản lý server. You want to deploy an app quickly without managing servers.
Kiến trúc gợi ý Suggested architecture
User → Cloudflare Pages frontend → Pages Function / Worker API → D1 / KV / R2 User → Cloudflare Pages frontend → Pages Function / Worker API → D1 / KV / R2
Sơ đồ tham chiếu (Cloudflare Docs) Reference diagrams (Cloudflare Docs)
Fullstack applications Fullstack applications
Ví dụ fullstack trên Developer Platform — Workers/Pages, storage và AI services trong một kiến trúc thực tế. A practical example of how these services come together in a real fullstack application architecture.
Thuật ngữ: Concepts: Workers · Pages · D1 · R2 · KV · Durable Objects
Sơ đồ chính thức ↗ Official diagram ↗ · Serverless Serverless
Serverless global APIs Serverless global APIs
An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other.
Thuật ngữ: Concepts: Workers · D1 · R2 · Global API · Edge compute
Sơ đồ chính thức ↗ Official diagram ↗ · Serverless Serverless
Controls & stack Controls & stack
- Website: Pages (static-first, cực nhanh) Website: Pages (static-first, very fast)
- API: Pages Functions hoặc Workers API: Pages Functions or Workers
- Relational data: D1 Relational data: D1
- Config/progress: KV Config/progress: KV
- File storage: R2 File storage: R2
- Bot protection: Turnstile Bot protection: Turnstile
- Analytics: Cloudflare Web Analytics Analytics: Cloudflare Web Analytics
Lỗi thường gặp Common mistakes
Deploy production trước khi test preview URL Shipping production before testing preview URLs
Mỗi PR có preview Pages — dùng để QA trước khi merge vào branch production. Each PR gets a Pages preview — use it for QA before merging to the production branch.
Binding D1/KV/R2 thiếu trên production env Missing D1/KV/R2 bindings on production env
Binding có thể khác giữa preview và production trong Pages settings. Kiểm tra cả hai environment. Bindings can differ between preview and production in Pages settings. Verify both environments.
Worker chạy logic nặng không phù hợp isolate Heavy logic unsuitable for Worker isolates
CPU-bound dài hoặc dependency lớn có thể cần Containers hoặc tách service — đừng nhồi hết vào một Worker. Long CPU-bound work or huge deps may need Containers or a split service — do not cram everything into one Worker.
Next step Next step
Tiếp tục hành trình học của bạn. Continue your learning journey.