HomeArchitecturesCloudflare Edge Computing Architecture
๐Ÿ—„๏ธ Data & InfrastructureAdvancedWeek 10

Cloudflare Edge Computing Architecture

Anycast routing, V8 isolates, and KV at the edge

CloudflareFastlyAWS Lambda@Edge

Key Insight

V8 isolates vs containers: isolates start in microseconds (shared process, separate heap), containers start in milliseconds (separate process). Orders of magnitude difference.

Request Journey

User's DNS query resolves to a Cloudflare anycast IP โ€” BGP routing directs the request to the nearest of 300+ PoPs worldwide (typically <20ms)โ†’
L3/L4 DDoS scrubbing (Magic Transit) drops volumetric attack traffic at the network edge using BPF filtersโ†’
L7 WAF applies managed rulesets (OWASP, bot detection) and custom rules to filter malicious HTTP requestsโ†’
CDN cache layer checks for a cached response using tiered caching (regional then global tiers)โ†’
On cache miss, request enters a Cloudflare Worker โ€” a V8 isolate that cold-starts in under 1ms (not a container, but an isolate sharing the V8 engine process)
+3 more steps

How It Works

1

โ‘  User's DNS query resolves to a Cloudflare anycast IP โ€” BGP routing directs the request to the nearest of 300+ PoPs worldwide (typically <20ms)

2

โ‘ก L3/L4 DDoS scrubbing (Magic Transit) drops volumetric attack traffic at the network edge using BPF filters

3

โ‘ข L7 WAF applies managed rulesets (OWASP, bot detection) and custom rules to filter malicious HTTP requests

4

โ‘ฃ CDN cache layer checks for a cached response using tiered caching (regional then global tiers)

5

โ‘ค On cache miss, request enters a Cloudflare Worker โ€” a V8 isolate that cold-starts in under 1ms (not a container, but an isolate sharing the V8 engine process)

6

โ‘ฅ Worker executes JavaScript/WASM logic, reading from Workers KV (global eventually-consistent store) or Durable Objects (single-instance strong consistency)

7

โ‘ฆ If the Worker needs origin data, it fetches via Argo Smart Routing (optimized network path)

8

โ‘ง Response is cached at the edge per Cache-Control headers and returned to the user

โš The Problem

Traditional CDNs cache static files, but modern applications require dynamic computation at the edge โ€” authentication, A/B testing, personalization, bot detection โ€” without the 50-200ms round trip to an origin server. Serverless functions in datacenters add latency; containers take seconds to cold-start.

โœ“The Solution

Cloudflare runs V8 JavaScript isolates โ€” not containers or VMs โ€” inside 300+ global Points of Presence. Isolates start in under 1ms (shared V8 process, isolated heap), enabling true serverless at the edge with geographic routing via anycast BGP. Workers KV and Durable Objects provide edge-local storage with strong consistency guarantees.

๐Ÿ“ŠScale at a Glance

300+

PoPs Worldwide

< 1ms

Worker Cold Start

< 1ms

KV Read Latency

1.2 trillion+

Requests Served/Day

๐Ÿ”ฌDeep Dive

1

Anycast BGP: Automatic Geographic Routing

Cloudflare announces the same IP addresses from all 300+ PoPs simultaneously using anycast BGP. The internet routing protocol automatically directs each user's packets to the topologically closest Cloudflare datacenter โ€” no DNS-based routing or client-side logic needed. This means a DDoS attack absorbs across hundreds of PoPs simultaneously, and every user gets sub-20ms latency to a Cloudflare node.

2

V8 Isolates vs. Containers

A Docker container starts a new OS process with 100ms+ cold start and its own memory space. A V8 isolate starts inside an existing V8 process in under 1ms โ€” it gets an isolated JavaScript heap but shares the V8 JIT compiler, garbage collector, and bytecode cache. Cloudflare runs thousands of isolates per physical machine, each for a different customer Worker, with cryptographic isolation between them. This density is impossible with containers.

3

Workers KV: Eventually-Consistent Edge Storage

Workers KV replicates key-value data to all 300+ PoPs with eventual consistency. Reads are always served locally (sub-1ms), but writes propagate within 60 seconds globally. This makes KV ideal for configuration data, feature flags, and user sessions where stale reads are acceptable. The model is similar to a CDN cache: high read performance, eventual write propagation.

4

Durable Objects: Stateful Actors at the Edge

Durable Objects solve KV's consistency limitations: each Durable Object is a stateful actor with a unique ID, guaranteed to run in exactly one location worldwide. All requests to a Durable Object are serialized โ€” enabling collaborative features, rate limiting counters, and WebSocket connection management with strong consistency. The object migrates automatically if its region becomes unhealthy.

5

The Request Lifecycle

A request to a Worker: DNS resolves to anycast IP, nearest PoP receives packet, TLS terminates with 1-RTT (0-RTT resumption for returning visitors), Worker isolate starts in under 1ms if warm or under 5ms cold, JavaScript executes, response returned. Total latency overhead versus serving a static file is about 5ms. This makes Workers viable for auth tokens, HTML rewriting, and API proxying that traditionally required origin round trips.

โฌกArchitecture Diagram

Cloudflare Edge Computing Architecture โ€” simplified architecture overview

โœฆCore Concepts

โš™๏ธ

Anycast BGP

โš™๏ธ

V8 Isolates

โš™๏ธ

Workers KV

โš™๏ธ

Durable Objects

โš™๏ธ

Service Workers

๐ŸŒ

Edge-side Rendering

โš–Tradeoffs & Design Decisions

Every architectural decision is a tradeoff. Here's what you gain and what you give up.

โœ“ Strengths

  • โœ“Sub-1ms cold starts enable true serverless at the edge without function warmup strategies
  • โœ“Anycast BGP provides automatic DDoS mitigation and geographic load balancing
  • โœ“Workers KV serves millions of reads/sec with sub-millisecond latency globally
  • โœ“No VMs or containers to manage โ€” pure code deployment

โœ— Weaknesses

  • โœ—Workers have strict CPU time limits (10-50ms) unsuitable for compute-intensive tasks
  • โœ—V8 isolate environment lacks Node.js stdlib โ€” porting existing code requires rewrites
  • โœ—Durable Object consistency requires routing all requests for a key to one location, adding latency for geographically distributed users
  • โœ—Workers KV eventual consistency (60s propagation) causes stale-read bugs if not carefully designed around

๐ŸŽฏFAANG Interview Questions

Interview Prep

๐Ÿ’ก These questions appear in FAANG system design rounds. Focus on tradeoffs, not just what the system does.

These are real system design interview questions asked at Google, Meta, Amazon, Apple, Netflix, and Microsoft. Study the architecture above before attempting.

  1. Q1

    Design a global rate limiter using Cloudflare Workers and Durable Objects. How do you handle the consistency vs. latency tradeoff?

  2. Q2

    Explain the difference between Cloudflare Workers KV and Durable Objects. When would you choose each?

  3. Q3

    Why can V8 isolates start in under 1ms while Docker containers take 100ms+? What are the security tradeoffs?

  4. Q4

    How does anycast BGP work? Why is Cloudflare's anycast network more DDoS-resilient than a unicast IP?

  5. Q5

    Design an edge authentication system using Workers. How do you validate JWTs without hitting an origin server?

Listen to the Podcast Episode

๐ŸŽ™๏ธ Free Podcast

Alex & Sam break it down

Listen to a conversational deep-dive on this architecture โ€” real trade-offs, production context, and student-friendly explanations. Free, no login required.

Listen to Episode

Free ยท No account required ยท Listen in browser

More Data & Infrastructure

View all
๐ŸŽ™๏ธ Podcast ยท All Free

Listen to more architecture deep-dives

30 free podcast episodes โ€” Alex & Sam break down every architecture in this library. Listen in your browser, no account needed.

All architecture articles are free ยท No account needed