After these two days of practice and various error reports, I need to correct the technical selection conclusion in Chapter 1.
ServerLess deployment overall consideration
I have figured out one thing: It is impossible for everyone to have the same development resources as me. In the medium and long term, the fastest, cheapest, integrated and replicable solution that can bring business to life can only be cloudflare for the entire ecosystem.
Price factors
Let’s first talk about the core factor that leads to this conclusion, price. Here are all the product series I have used:
- Database: Supabase, Aws Rds, self-built server, MongoDB Atlas, CockroachDB, Firebase Firestore, etc. - ServerLess: Aws S3, Railway, Vercel, Netlify, etc. - Memory kv: self-built Redis, Upstash Redis, AWS ElastiCache, Memcached, etc. - Queue: RabbitMQ, Kafka, AWS SQS, Upstash Kafka, Google Pub/Sub, Azure Service Bus, etc.
I have come to a conclusion: D1, Pages, Workers, KV, Queues, and R2 of the Cloudflare ecosystem are the cheapest on the market in the long run, bar none.
Anyone who recommends Vercel, Supabase, and Upstash will definitely pay the price when his business improves! Of course, it’s definitely possible to just do a demo.
Ecological unification factors
In addition to the price advantage, the unity of the Cloudflare ecosystem is another important consideration:
1. Single Control Panel: All services are managed in the same Dashboard, no need to switch between multiple platforms.
2. Seamless integration: Cloudflare’s services are designed to work seamlessly together. For example, Workers can directly access KV, D1 and R2; Pages can automatically trigger the deployment of Workers; Queues can be directly integrated with Workers to process asynchronous tasks.
3. Unified development model: All services follow a similar development paradigm. Once you learn the development method of Workers, the use of other services becomes simple.
4. Edge-first design: All services are designed to run on the edge network, which means that your application is naturally globally distributed and does not require additional configuration of CDN or geographical routing.
5. Unified security model: The same security policy can be configured for the entire application stack, including WAF, Bot management, DDoS protection, etc., instead of configuring each component individually.
Ecological operability
When we are familiar with cloudflare, we can complete batch page deployment and database deployment very simply and quickly~
Question
- Highly ecologically invasive - Extremely difficult to adapt - Logs are not easy to troubleshoot - Without external community ecology, you can only be a primitive person - Excessive learning costs
But there is no way, this is what the poor have to accept, because the cost savings it can give you are W level.
Introduction to Cloudflare ecological core services
Let’s take a closer look at these core services in the Cloudflare ecosystem, which together form a complete application development platform:
Cloudflare Workers
Workers is the core computing platform of the Cloudflare ecosystem. It is a Serverless JavaScript/TypeScript execution environment based on the V8 engine and runs on Cloudflare's global edge network.
- Features: Extremely short cold start time (<1ms), global distribution, support for ES modules - Purpose: API development, dynamic content generation, request forwarding, identity verification, A/B testing, etc. - Pricing: Free for the first 100,000 requests per day, $0.50/million requests thereafter - Limitations: The free plan has a single execution limit of 10ms CPU time, the paid plan is 50ms
Cloudflare Pages
Pages is Cloudflare's static website hosting and Serverless front-end application platform that supports automatic building and deployment from Git repositories.
- Features: Automatic CI/CD, preview deployment, custom domain name, global CDN distribution - Purpose: Hosting static websites, SPA applications, SSG websites, Next.js applications, etc. - Pricing: Unlimited deployments and bandwidth are completely free, with usage restrictions only on Pages Functions (Workers-based) - Integration: Can be seamlessly integrated with Workers, D1, KV, etc.
Cloudflare D1
D1 is a Serverless SQL database built by Cloudflare based on SQLite and is fully integrated into the Workers ecosystem.
- Features: No server management required, global distribution, compatible with SQLite - Use: Store structured data, suitable for main database of small and medium-sized applications
Alternatives to Pg
Cloudflare KV
KV is Cloudflare's globally distributed key-value storage service, designed for high-read, low-write scenarios.
- Features: Global consistency, low latency reads, direct access from Workers - Purpose: caching, configuration storage, session management, feature flags, etc. - Pricing: Free plan includes 1GB storage and 100,000 reads/1,000 writes, then $0.50/million reads and $5/million writes - Limitations: The size of a single value is limited to 25MB, which is not suitable for frequent writing scenarios.
Redis alternatives
Cloudflare R2
R2 is Cloudflare's object storage service that is compatible with the S3 API but has no outbound data transfer fees.
- Features: No outbound fees, global distribution, S3 compatible API - Purpose: Store user uploaded files, static resources, backups, logs, etc. - Pricing: Free for the first 10GB of storage and 10 million Class A operations per month, then $0.015/GB of storage - Advantages: No expensive data outbound charges compared to services such as AWS S3
Alternatives to S3
Cloudflare Queues
Queues is Cloudflare's distributed message queue service for asynchronous task processing and system decoupling.
- Features: Global distribution, seamless integration with Workers, FIFO guarantee - Use: asynchronous task processing, inter-system communication, event-driven architecture, etc. - Pricing: Free for the first 1 million operations per month, $0.50/million operations thereafter - Limitations: Message retention time is up to 24 hours, and single message size is limited to 128KB
Kafka alternatives
Together, these services form a complete application development platform, from front-end to back-end, from computing to storage, from synchronous to asynchronous processing, covering almost all the needs of modern web application development. The most important thing is that they are all billed according to usage, and this free quota is very large. To be honest, cloudflare will give you 10$ for a month’s service of 2,000$, which is truly a cyber bodhisattva.
Obviously, everything else except Cloudflare Queues can be used in our project.
About ORM selection
Originally, I wanted to choose Prisma, but the problem was that it had poor adaption and support for the D1 database (it was too much work to change, so I gave up). In the end, after shopping around, I could only choose the ORM drizzle.
The main reason for choosing it is: it does not have any third-party dependencies! (Dependency problems are the most painful and difficult to solve in ServerLess).

And it is relatively close to the dialect SQL writing method of mainstream databases, but it has type hints and function hints.
End
As for D1 and drizzle, there will be an article analyzing their writing methods and operations (sadly, no one on the market has written this series together, so I will add some basic information for everyone, which can be compared during the database operation of subsequent projects).