Edge Functions Guide: Cloudflare Workers, Lambda@Edge, and Deno Deploy

· Mei-Lin Wu · 7 min read

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.

Edge Computing Architecture — Cloud, Edge, and Device tiersEdge Computing Architecture — Cloud, Edge, and Device tiers Edge Computing Architecture — Cloud to Device Cloud Tier Origin servers, databases, ML training Latency: 100–300ms Storage Compute Edge Tier CDN PoPs, edge functions, KV stores, caching Latency: 5–30ms Workers KV Cache Device Tier Browser cache, service workers, local storage Latency: < 1ms Browser Mobile
Figure 1: Edge Computing Architecture — Cloud, Edge, and Device tiers

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.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.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.

Edge Function Runtime — Internal components of edge compute platformEdge Function Runtime — Internal components of edge compute platform CDN Edge Server Architecture Load Balancer L4/L7 + Health Checks TLS Termination Certificate Management OCSP Stapling Cache Engine SSD + RAM Cache Cache-Control Parser WAF Engine Rule Processing Bot Detection Request Router URL Rewriting + Edge Logic Logging & Metrics Real-time Analytics Origin Fetch Module Connection Pooling · Retry Logic · Timeout Management
Figure 2: Edge Function Runtime — Internal components of edge compute platform

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?

FeatureCloudflare WorkersLambda@EdgeDeno DeployVercel Edge Functions
Isolation modelV8 isolatesMicro-containersV8 isolatesV8 isolates (via CF)
Cold start<1 ms50–500 ms<10 ms<1 ms
Global PoPs300+450+ (CloudFront)35+300+ (via CF)
Deploy speed<30 seconds5–15 minutes<60 seconds<60 seconds
Max CPU time10–50 ms5–30 s (varies)50 ms (free)Varies by plan
Max memory128 MB128 MB–10 GB512 MB128 MB
Native storageKV, DO, R2, D1DynamoDB, S3Deno KVVercel KV, Blob
WASM supportYesNoYesYes
Free tier100K req/day1M req/month (Lambda)100K req/day100K 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:

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.

External References

References & Standards: OWASP CDN Security · HTTP/2 specification