ADR 002: Cloudflare Workers as Edge Platform

Status: Accepted Date: 2025-03-15 Last Updated: 2026-02-26

Context

We need a backend platform for API gateway, BFF workers, static asset serving, version config management, and real-time WebSocket features. The platform should support globally distributed edge computing with minimal ops overhead.

Decision

Use Cloudflare Workers with the full ecosystem: R2 (storage), KV (key-value), D1 (SQL), Durable Objects (stateful coordination), and service bindings (inter-Worker RPC). Use Wrangler v4 for local development and deployment (Wrangler v3 is EOL as of Q1 2026). Set compatibility_date = "2026-02-25" in all wrangler configuration files.

Cloudflare Workers Decision Card Cloudflare Workers Positive 0ms cold start 300+ PoPs Service bindings Durable Objects Negative Not Node.js 128MB limit Vendor lock-in

Consequences

Positive

  • 0ms cold start (V8 isolates, not containers)
  • Global deployment to 300+ data centers
  • Service bindings: zero-latency, zero-cost inter-Worker communication
  • Durable Objects with Hibernatable WebSockets for cost-efficient real-time; supports up to 32 MiB WebSocket messages
  • R2 for S3-compatible object storage (MFE bundles) with no egress fees
  • KV for globally distributed config reads (30s minimum cacheTtl; supports read-your-own-writes (RYOW) consistency for writes followed by reads on the same node)
  • D1 for SQL (audit trail, version history) with no server management -- GA since April 2024, 1TB per-account storage limit
  • $5/month paid plan covers 10M requests
  • Wrangler v4 CLI for local development and deployment
  • CPU time is configurable up to 5 minutes via cpu_ms in wrangler.toml (default 30ms on Workers Paid)

Negative

  • Workers runtime is NOT Node.js (limited API surface, no fs, no native modules)
  • 128MB memory limit per Worker
  • Vendor lock-in to Cloudflare ecosystem
  • Durable Objects have ~1000 req/sec per-object limit
  • KV is eventually consistent (~250ms global p99 latency; the frequently cited <5ms figure applies only to internal KVSP cache hits, not global propagation)

Alternatives Considered

  • AWS Lambda@Edge / CloudFront Functions: More mature ecosystem but cold starts (100-500ms), higher cost, complex IAM, no equivalent to Durable Objects or service bindings.
  • Vercel Edge Functions: Good DX but limited to Vercel platform, no equivalent to Durable Objects, R2, or D1. Less control over infrastructure.
  • Traditional servers (Node.js on ECS/GKE): Full Node.js API but requires managing servers, scaling, load balancing. Higher ops overhead, higher cost at scale.
  • Deno Deploy: Good V8-based edge platform but smaller ecosystem, less mature storage primitives, no equivalent to Durable Objects.