Cloudflare Workers moved from isolated “edge function” to complete edge platform during 2023-2024. Now: Workers (compute) + KV (global key-value) + D1 (distributed SQLite) + R2 (S3-compatible object storage) + Durable Objects (stateful) + Queues + Workers AI (edge GPU inference). This article covers the stack and when it seriously competes with AWS.
The Components
Workers — Compute
- V8 isolates, cold start <5ms.
- ~330+ global PoPs.
- $5/mo baseline, $0.30/1M requests.
- JavaScript, TypeScript, Rust (via Wasm), Python (beta).
KV — Global Key-Value
- Eventual consistency.
- Low read latency (ms).
- ~$5/mo, $0.50 per 1M reads.
- Case: distributed cache, session tokens.
D1 — Edge SQLite
- Distributed SQLite with replication.
- Full SQL.
- GA since 2024.
- Pricing based on rows read/written.
- Case: small-mid CRUD apps.
R2 — Object Storage
- S3 API compatible.
- No egress fees — massive advantage.
- ~$0.015/GB/mo.
- Case: images, videos, files.
Durable Objects
- Stateful edge compute.
- Strong per-object consistency.
- Persistent WebSockets.
- Case: chat rooms, collaborative apps, rate limiting.
Queues
- Simple pub-sub.
- FIFO delivery.
- Case: async processing.
Workers AI
- Edge GPU LLM inference.
- Llama, Mistral, others.
- Pay per token.
- Case: chatbots, summarisation, image generation.
Why It Matters
Complete stack for edge apps without AWS:
[User]
→ Cloudflare edge (Worker)
↓ KV (cache)
↓ D1 (DB)
↓ R2 (storage)
↓ Durable Objects (stateful)
↓ Workers AI (LLM)
Typical p50 latency to user: <50ms. AWS-equivalent requires Lambda@Edge + DynamoDB Global + S3 + ElastiCache + Bedrock — more complex, more expensive, more lock-in.
Cloudflare vs AWS for Edge
| Aspect | Cloudflare | AWS |
|---|---|---|
| Regions | 330+ PoPs | ~30 regions |
| Cold start | <5ms | 100ms+ (Lambda) |
| Entry price | $5/mo | complex |
| Egress | Free (R2) | $0.09/GB |
| Vendor lock-in | Moderate | Moderate |
| Enterprise tooling | Growing | Mature |
| Ecosystem | Smaller | Massive |
Cloudflare wins on simple edge + egress cost. AWS wins on ecosystem and enterprise features.
Real Cases That Fit
Where Cloudflare stack shines:
- Global edge APIs: user near any PoP.
- Static + dynamic sites: Next.js, Astro on Workers.
- Chat apps: perfect Durable Objects.
- Edge image optimization: Workers + R2.
- Global rate limiting: Durable Objects.
- Rapid prototyping: fast setup, low costs.
Cases Where AWS Still Wins
- Compute-intensive workloads: Lambda limits, Workers 30s max.
- Mature managed DBs: RDS Postgres vs D1 (young D1).
- Streaming data: Kinesis, MSK.
- ML platform: SageMaker.
- Complex IAM: AWS IAM is richer.
Deployment
wrangler is the CLI:
npm install -g wrangler
wrangler login
# Create worker
wrangler init my-app
# Deploy
wrangler deploy
# Tail logs
wrangler tail
Seconds-long deployment. No containers, no buckets to configure first.
Framework Integrations
- Next.js: OpenNext adapter.
- Nuxt: Nitro supports Cloudflare.
- SvelteKit: adapter-cloudflare.
- Hono: multi-runtime including Workers.
- Astro: adapter-cloudflare.
- Remix: adapter.
Strong ecosystem support.
Workers AI in Practice
export default {
async fetch(request, env) {
const response = await env.AI.run("@cf/meta/llama-3-8b-instruct", {
messages: [{ role: "user", content: "Hi" }],
});
return Response.json(response);
},
};
LLM inference with <1s edge latency. No GPU management. Pay per token.
Limitations
Honest:
- 30s max request: no long-running compute.
- Read-only D1 replicas (centralised writes).
- Durable Objects limited concurrency per object.
- Initial Python support (beta).
- Less rich debugging than serverful environments.
- Workers bundle size limit (~1-10MB depending plan).
Real Prices
Mid-size app (1M users/mo, 10M requests):
- Workers: $5 base + negligible.
- KV (1M reads): $0.50.
- D1 (1M reads): ~$1.
- R2 (10GB storage): $0.15.
- Total: ~$10/mo.
AWS-equivalent typically $50-200/mo with similar workload.
Compliance
Cloudflare offers:
- SOC 2, ISO 27001.
- GDPR compliant: EU region options.
- HIPAA BAA available.
- FedRAMP in progress.
Fast maturation in certifications.
Migration from Node.js Server
If you have Express app on EC2/Heroku:
- Adapt to Hono or similar Worker-compatible framework.
- Migrate DB to D1 or external Postgres.
- Session storage → KV or Durable Objects.
- File storage → R2.
- Deploy:
wrangler deploy.
Project takes days to weeks depending on complexity.
Conclusion
Cloudflare edge stack in 2024 is real alternative to AWS for many cases. For edge-native apps (global, latency-sensitive, medium complexity), it’s simpler, cheaper, and faster. For enterprise workloads with complex compliance or specific ecosystems, AWS remains primary option. Gap closes every month — worth evaluating for new projects before defaulting to AWS.
Follow us on jacar.es for more on edge computing, Cloudflare, and global architectures.