Edge Functions Guide: Cloudflare Workers, Lambda@Edge, and Deno Deploy
Edge functions are lightweight server-side programs that execute at CDN Points of Presence rather than a centralized origin data center. By processing requests within milliseconds of the end user, they eliminate origin round-trips for tasks like authentication, A/B testing, header manipulation, and dynamic content assembly. The three dominant platforms — Cloudflare Workers, AWS Lambda@Edge, and Deno Deploy — each implement this concept differently, and choosing the right one depends on your performance requirements, existing infrastructure, and developer workflow. For a comprehensive overview, see our guide on Edge Computing on CDN: Moving Logic to the Edge — FlyFish NWA.
What Are Edge Functions and How Do They Work?
An edge function is a small unit of server-side code deployed to dozens or hundreds of geographically distributed nodes within a CDN network. When a user request arrives at the nearest Point of Presence, the edge function intercepts it before it reaches the origin server. The function can modify request headers, rewrite URLs, generate entire responses, or selectively proxy to the origin — all without the latency penalty of a centralized server.
The fundamental architectural difference between edge function platforms lies in their isolation model. Cloudflare Workers and Deno Deploy use V8 isolates — lightweight execution contexts within a shared JavaScript engine process. Each isolate has its own memory heap but shares the underlying operating system resources, enabling cold starts under one millisecond. AWS Lambda@Edge uses micro-containers that provide stronger isolation but require 50 to 500 milliseconds to initialize. This distinction shapes every downstream trade-off in performance, resource limits, and language support.
How Does Cloudflare Workers Handle Execution at the Edge?
Cloudflare Workers runs on every server across Cloudflare's network of 300+ cities worldwide. Unlike traditional CDN architectures with tiered caching layers, Cloudflare's flat network topology means every node is both a cache server and a compute node. This eliminates the need to route edge function requests to specialized compute regions.
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
Runtime and Resource Limits
Workers uses the V8 JavaScript engine without a full Node.js or browser environment. The free tier allows 100,000 requests per day with a 10-millisecond CPU limit per invocation. The paid Bundled plan ($5/month base) raises this to 50 milliseconds of CPU time and 30 seconds of wall-clock time, accommodating asynchronous operations like fetch calls that do not consume CPU while waiting.
Integrated Storage Ecosystem
What sets Workers apart is its tightly coupled storage layer. Workers KV provides an eventually consistent key-value store optimized for read-heavy workloads, delivering sub-10-millisecond reads at the edge. Durable Objects offer single-instance, strongly consistent coordination primitives ideal for rate limiting, WebSocket management, and collaborative applications. R2 delivers S3-compatible object storage with zero egress fees. D1 brings SQLite to the edge, replicating databases closer to requesting users. Together, these services let developers build stateful applications entirely within the edge network.
What Makes Lambda@Edge Different from Standard AWS Lambda?
Lambda@Edge extends AWS Lambda to CloudFront's 450+ edge locations. Functions are authored and versioned in the us-east-1 region, then replicated globally. This replication model introduces a 5-to-15-minute deployment delay — a significant difference from Workers' sub-30-second global propagation.
Trigger Points and Execution Context
Lambda@Edge offers four trigger points within the CloudFront request lifecycle: viewer-request, origin-request, origin-response, and viewer-response. Viewer-facing triggers run with tighter constraints (128 MB memory, 5-second timeout) because they execute on every request. Origin-facing triggers allow up to 10 GB of memory and 30-second timeouts because they only fire on cache misses. CloudFront Functions, a lighter alternative, handle viewer-level manipulations with sub-millisecond startup but support only JavaScript and a restricted API surface.
AWS Ecosystem Integration
The primary advantage of Lambda@Edge is deep integration with the AWS stack. Functions can validate signed URLs and cookies, enforce IAM policies, read from DynamoDB Global Tables, and trigger Step Functions. For organizations already running on AWS, this eliminates the operational overhead of adopting a separate edge platform. The trade-off is higher cold-start latency and a more complex deployment pipeline compared to isolate-based platforms.
How Does Deno Deploy Compare to Workers and Lambda@Edge?
Deno Deploy runs Deno — a secure JavaScript and TypeScript runtime — across 35+ regions on Google Cloud's network. It uses V8 isolates like Workers but provides a broader API surface, including native support for the Deno standard library, Web APIs (Fetch, Streams, Crypto), and npm package imports via the npm: specifier.
Deno Deploy cold starts are under 10 milliseconds. The free tier includes 100,000 requests per day and 100 GiB of bandwidth. Paid plans start at $20 per month with higher CPU and bandwidth limits. Deno KV, a globally distributed key-value database, provides strong consistency within a region and eventual consistency across regions — positioning it between Workers KV (eventually consistent everywhere) and Durable Objects (strongly consistent but single-location).
The Fresh framework, Deno's official web framework, deploys natively to Deno Deploy with island-based hydration for optimal frontend performance. This makes Deno Deploy particularly attractive for full-stack applications where the edge function serves both API endpoints and server-rendered pages.
Where Does Vercel Edge Functions Fit In?
Vercel Edge Functions run on Cloudflare's network under the hood but are accessed through Vercel's deployment platform and Next.js middleware API. They support the Edge Runtime — a subset of Node.js APIs — and integrate directly with Vercel's build pipeline, making them the natural choice for Next.js applications. The abstraction trades direct platform control for developer convenience: you deploy a Next.js app, and edge middleware automatically runs at the CDN layer without separate infrastructure configuration.
How Do Edge Function Platforms Compare on Key Metrics?
| Feature | Cloudflare Workers | Lambda@Edge | Deno Deploy | Vercel Edge Functions |
|---|---|---|---|---|
| Isolation model | V8 isolates | Micro-containers | V8 isolates | V8 isolates (via CF) |
| Cold start | <1 ms | 50–500 ms | <10 ms | <1 ms |
| Global PoPs | 300+ | 450+ (CloudFront) | 35+ | 300+ (via CF) |
| Deploy speed | <30 seconds | 5–15 minutes | <60 seconds | <60 seconds |
| Max CPU time | 10–50 ms | 5–30 s (varies) | 50 ms (free) | Varies by plan |
| Max memory | 128 MB | 128 MB–10 GB | 512 MB | 128 MB |
| Native storage | KV, DO, R2, D1 | DynamoDB, S3 | Deno KV | Vercel KV, Blob |
| WASM support | Yes | No | Yes | Yes |
| Free tier | 100K req/day | 1M req/month (Lambda) | 100K req/day | 100K req/month |
| Pricing base | $5/month | $0.60/M requests | $20/month | $20/month |
What Are the Best Use Cases for Edge Functions?
Edge functions excel at request-level logic that benefits from geographic proximity to the user. The most common production use cases include:
- Authentication and authorization: Validating JWTs, API keys, or session cookies at the edge prevents unauthorized requests from ever reaching the origin, reducing both latency and origin load.
- A/B testing and feature flags: Assigning users to experiment buckets at the edge eliminates the flash of unstyled content that client-side testing creates, without adding server-side latency.
- Geo-based personalization: Serving localized content, currency, or regulatory notices based on the user's geographic location without origin calls.
- Request routing and rewriting: Implementing vanity URLs, legacy redirects, or Backend-for-Frontend patterns at the network edge.
- Security enforcement: Rate limiting, bot detection, and security header injection before traffic reaches origin infrastructure.
When Should You Avoid Edge Functions?
Edge functions are not a universal replacement for traditional serverless or server-based architectures. CPU-intensive workloads like video transcoding, machine learning inference, or complex data transformations exceed edge CPU limits and belong at the origin. Applications requiring persistent database connections face challenges because edge functions are stateless and ephemeral — each invocation may run on a different node with no shared memory. Large dependency bundles (over 1–5 MB depending on the platform) increase cold start times and may exceed size limits entirely.
The golden rule is: if the computation takes longer than the network round-trip it would save, keep it at the origin. Edge functions provide the most value for lightweight, latency-sensitive operations measured in single-digit milliseconds of CPU time.
How Do You Get Started with Edge Functions?
Each platform provides a CLI-based workflow for local development and deployment. Cloudflare's wrangler CLI scaffolds a project, runs a local development server with the Workers runtime, and deploys globally with a single command. AWS uses the SAM CLI or CDK to define Lambda@Edge functions alongside CloudFront distributions. Deno Deploy integrates with GitHub for automatic deployments on push, or uses the deployctl CLI for manual deployment.
The conceptual pattern is the same across all platforms: export a handler function that receives a request object, processes it, and returns a response. The handler can fetch from the origin, read from edge storage, modify headers, or generate a response entirely at the edge. Start with a simple use case — adding a security header or redirecting based on country code — and expand as you build confidence in the platform's constraints and performance characteristics.
For teams evaluating platforms, the decision matrix is straightforward. If you prioritize cold start performance and developer velocity, choose Cloudflare Workers. If you are invested in the AWS ecosystem and need deep service integration, Lambda@Edge is the pragmatic choice. If you value standards compliance and the Deno ecosystem, Deno Deploy offers the most modern runtime. And if you are building with Next.js, Vercel Edge Functions provide the smoothest integration path with minimal configuration overhead.