Jacar mascot — reading along A laptop whose eyes follow your cursor while you read.
Arquitectura Tecnología

Cloudflare Workers in 2024: KV, D1, and the New Edge Stack

Cloudflare Workers in 2024: KV, D1, and the New Edge Stack

Actualizado: 2026-05-03

Cloudflare Workers moved from isolated edge function to complete edge platform during 2023-2024. The current stack combines 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 analyses when that stack seriously competes with AWS and when AWS remains the right answer.

Key takeaways

  • V8 isolates with sub-5ms cold starts deliver sub-50ms p50 latency to users from any of 330+ PoPs.
  • R2 eliminates egress fees — the most differentiated cost advantage versus S3.
  • D1 (edge SQLite) reached GA in 2024 and covers small-to-mid CRUD apps well.
  • Durable Objects are the right primitive for persistent WebSockets, global rate limiting, and collaborative apps.
  • The 30-second request limit blocks long-running compute — that is the most important structural constraint.

The stack components

Workers — compute

  • V8 isolates, cold start under 5 ms.
  • Over 330 global PoPs.
  • $5/mo base price, $0.30 per million requests.
  • JavaScript, TypeScript, Rust (via Wasm), Python in beta.

KV — global key-value

  • Eventual consistency; millisecond read latency.
  • Natural use case: distributed cache, session tokens.

D1 — edge SQLite

  • Replicated SQLite. Full SQL. GA since 2024.
  • Pricing based on rows read and written.
  • Use case: small-mid CRUD apps. Centralised writes, read replicas at each PoP.

R2 — object storage

  • S3-API compatible. No egress fees — massive advantage versus AWS S3.
  • Approximately $0.015/GB/mo.
  • Use case: images, videos, static files.

Durable Objects

  • Stateful edge compute. Strong per-object consistency. Persistent WebSockets.
  • Use case: chat rooms, collaborative apps, global rate limiting.

Workers AI

  • Edge GPU LLM inference (Llama, Mistral, others). Pay per token.
  • Use case: chatbots, summarisation, image generation.

Cloudflare vs AWS for edge

Aspect Cloudflare AWS
Regions 330+ PoPs ~30 regions
Cold start <5ms 100ms+ (Lambda)
Egress Free (R2) $0.09/GB
Edge DB D1 (SQLite) — (DynamoDB Global is different)
Execution limit 30s 15 min (Lambda)
Ecosystem Growing Mature and massive

Cloudflare wins on simple edge, latency and egress cost. AWS wins on enterprise ecosystem, mature managed databases, and compute-intensive or long-running workloads. The Fastly Compute article covers how another provider approaches the same space with more mature enterprise contracts.

Cases where Cloudflare fits

  • Global edge APIs: user near any PoP, sub-20ms latency.
  • Next.js / Astro / SvelteKit sites: see SvelteKit 1.0 and its real adoption for the adapter-cloudflare integration.
  • Chat apps: Durable Objects with persistent WebSockets are exactly built for this.
  • Edge image optimisation: Workers + R2 eliminates the origin round-trip.
  • Global rate limiting: Durable Objects with strong per-object consistency.
  • Rapid prototyping: setup in minutes, negligible cost at low volumes.

Cases where AWS still wins

  • Intensive or long-running compute: Lambda accepts up to 15 minutes; Workers has a 30s limit.
  • Mature managed DBs: RDS PostgreSQL versus D1, which is young.
  • Streaming data: Kinesis, MSK.
  • ML platforms: SageMaker.
  • Complex IAM: AWS permission model is far richer.

Deployment with Wrangler

bash
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.

Workers AI in practice

typescript
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 under-1s edge latency. No GPU management. Pay per token. It complements architectures where the main model is accessible via LLM proxies like LiteLLM to manage multiple providers.

Honest limitations

  • 30s max request: no long-running compute.
  • Read-only D1 replicas: writes remain centralised.
  • Durable Objects: limited concurrency per object.
  • Python in beta: not production-ready without prior validation.
  • Less rich debugging than serverful environments.
  • Bundle size limit (~1-10MB depending on 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.
  • Approximate total: ~$10/mo.

The AWS equivalent typically runs $50-200/mo with similar workload.

Conclusion

The Cloudflare edge stack in 2024 is a real AWS alternative for many cases. For edge-native applications — global, latency-sensitive, medium complexity — it is simpler, cheaper, and faster to operate. For enterprise workloads with complex compliance, specific ecosystems, or intensive compute, AWS remains the primary option. The gap closes every month: it is worth evaluating Cloudflare for new projects before defaulting to AWS.

Was this useful?
[Total: 13 · Average: 4.5]

Written by

CEO - Jacar Systems

Passionate about technology, cloud infrastructure and artificial intelligence. Writes about DevOps, AI, platforms and software from Madrid.