Skip to content

ADR-001: Cloudflare Workers Platform Selection

ADR-001: Cloudflare Workers Platform Selection

Section titled “ADR-001: Cloudflare Workers Platform Selection”

Accepted

2025-09-01

We needed to select a platform for building a MySQL-compatible edge database that could:

  • Provide global edge distribution with low latency
  • Handle stateful database operations
  • Support MySQL protocol compatibility
  • Scale automatically without infrastructure management
  • Integrate with modern edge computing paradigms

Key requirements:

  • Sub-50ms query response times globally
  • Support for complex SQL operations including transactions
  • Multi-tenant isolation and security
  • Cost-effective scaling from zero to enterprise volumes
  • Developer-friendly deployment and debugging

Alternative platforms considered:

  1. Traditional Cloud Providers (AWS, GCP, Azure)
  2. Edge Computing Platforms (Fastly Compute, Vercel Edge Functions)
  3. Serverless Platforms (AWS Lambda, Azure Functions)
  4. Cloudflare Workers

We chose Cloudflare Workers as the primary platform for WorkerSQL implementation.

  1. Global Edge Network: 300+ locations worldwide with sub-10ms latency to 95% of internet users
  2. Stateful Capabilities: Durable Objects provide strongly consistent, stateful computing primitives
  3. Integrated Storage Options: KV (eventually consistent), D1 (SQLite), R2 (object storage), Queues
  4. V8 Isolates: Faster cold starts (sub-millisecond) compared to container-based solutions
  5. Cost Model: Pay-per-request with generous free tier, predictable pricing
  6. Developer Experience: TypeScript-first, excellent local development tools (Miniflare, Wrangler)
  7. Security: Automatic DDoS protection, built-in security features

Traditional Cloud Providers:

  • ❌ Higher latency due to regional deployment
  • ❌ Complex infrastructure management required
  • ❌ Higher operational overhead
  • ✅ Mature ecosystem and enterprise features

Other Edge Platforms:

  • ❌ Limited stateful computing capabilities
  • ❌ Lack of integrated database solutions
  • ❌ Smaller global footprint
  • ❌ Less mature development tooling

Serverless Platforms:

  • ❌ Cold start latency issues
  • ❌ Limited execution duration
  • ❌ No built-in state management
  • ❌ Regional rather than edge deployment
  • Durable Objects: Enable authoritative, stateful database shards at the edge
  • KV Storage: Provides fast, eventually consistent caching layer
  • D1 Database: Offers SQLite compatibility for complex queries
  • Queues: Enable reliable async processing for cache invalidation
  • Workers Platform: Handles HTTP/MySQL protocol termination
  • Ultra-low latency database operations globally
  • Simplified deployment and scaling
  • Cost-effective from prototype to enterprise scale
  • Strong TypeScript development experience
  • Built-in security and DDoS protection
  • Automatic geographic distribution
  • Platform lock-in to Cloudflare ecosystem
  • Limited by Workers execution model constraints
  • Newer platform with evolving feature set
  • Learning curve for edge-first architecture patterns
  • Dependency on Cloudflare’s service reliability
  • Implement abstraction layers for potential platform portability
  • Design architecture to be compatible with other edge platforms
  • Maintain fallback strategies for critical operations
  • Regular platform capability assessment and roadmap alignment
  • Must design for distributed, eventually consistent systems
  • Need to handle network partitions and edge failures gracefully
  • Architecture must work within Workers’ execution limits
  • Security model aligned with Cloudflare’s zero-trust approach