Cloudflare Edge Computing Architecture
Anycast routing, V8 isolates, and KV at the 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
How It Works
โ 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)
โฅ Worker executes JavaScript/WASM logic, reading from Workers KV (global eventually-consistent store) or Durable Objects (single-instance strong consistency)
โฆ If the Worker needs origin data, it fetches via Argo Smart Routing (optimized network path)
โง 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
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.
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.
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.
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.
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.
- Q1
Design a global rate limiter using Cloudflare Workers and Durable Objects. How do you handle the consistency vs. latency tradeoff?
- Q2
Explain the difference between Cloudflare Workers KV and Durable Objects. When would you choose each?
- Q3
Why can V8 isolates start in under 1ms while Docker containers take 100ms+? What are the security tradeoffs?
- Q4
How does anycast BGP work? Why is Cloudflare's anycast network more DDoS-resilient than a unicast IP?
- Q5
Design an edge authentication system using Workers. How do you validate JWTs without hitting an origin server?
Listen to the Podcast Episode
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 EpisodeFree ยท No account required ยท Listen in browser
More Data & Infrastructure
View allSpotify Music Recommendation System
Collaborative filtering, Discover Weekly, and the AudioEmbeddings pipeline
Spotify ยท Apple Music ยท YouTube Music
GitHub Pull Request & CI/CD Pipeline
Git internals, check suites, and the webhook fanout that powers DevOps
GitHub ยท GitLab ยท Bitbucket
LinkedIn Feed Ranking Architecture
Heavyweight ML scoring with online/offline feature pipelines
LinkedIn ยท Facebook ยท Twitter
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