Back to BlogEngineering

Why We Switched from AWS to Cloudflare for Edge Deployments

TechZunction Team5 December 20258 min read

For three years, we deployed edge functions on AWS Lambda@Edge through CloudFront. It worked, but the developer experience was painful — cold starts of 200 to 500 milliseconds, a 5-second execution limit, no access to environment variables at the edge, and deployment times measured in minutes because CloudFront distributions propagate globally at their own pace. When Cloudflare Workers matured to the point of supporting full-stack applications with D1 (SQLite at the edge), R2 (object storage), and Queues, we ran a 60-day migration pilot with two client projects.

The results were decisive. P50 latency dropped from 180ms to 12ms — that is not a typo. Cloudflare Workers run on V8 isolates instead of containers, so there are no cold starts. The execution model is fundamentally different: instead of spinning up a container for each invocation, your code runs in a lightweight isolate that starts in under 5 milliseconds. For an API endpoint that serves personalised content based on geolocation, this meant users in Mumbai, Delhi, and Chennai all experienced sub-50ms response times instead of the 150-300ms range we saw with Lambda@Edge.

The cost reduction was equally dramatic. Lambda@Edge bills per request plus compute duration, and CloudFront charges for data transfer. Cloudflare Workers includes 10 million requests per month on their paid plan at 5 dollars, with additional requests at 0.50 dollars per million. For one client processing 40 million edge requests per month, the monthly bill dropped from 1,200 dollars on AWS to 350 dollars on Cloudflare — a 70% reduction. And that includes D1 database queries, R2 storage, and KV reads that would be separate line items on AWS.

The migration itself was smoother than expected. Cloudflare Workers use standard Web APIs (fetch, Request, Response, crypto), so most of our Lambda@Edge code ported over with minimal changes. The main refactoring was replacing AWS SDK calls with Cloudflare bindings — D1 for database queries, R2 for file storage, and KV for key-value caching. We wrapped these in a thin abstraction layer so our application code remains cloud-agnostic, but in practice, we have not looked back. The combination of performance, cost, and developer experience makes Cloudflare our default recommendation for edge workloads.

Stay in the loop

Get our latest articles on engineering, design, and building digital products — delivered straight to your inbox.