Cloudflare CDN
medium 24 minCloudflare is a reverse proxy that runs in hundreds of cities behind the same anycast addresses.
See it run
Follow a request through anycast, filters, Workers and two cache tiers, then change the content and break parts of it.
Operations
Miss, tier, hit
Two cities ask for the same file. The origin answers once.
Step 1 of 6
Paris asks
Miss in Paris
Anycast brings the visitor to the Paris data centre. It has no copy.
Step 1: Paris asks
lookup(edge)if miss: lookup(upper tier)if miss: fetch from origin, oncestore on the way back- When
- First request
- You leave with
- Two warm tiers
Say which tier absorbs which miss. That is the whole calculation of origin load.
In the real world
The same cloudflare cdn doing real jobs. Pick one and step through it.
What visitors see when your server fails.
Step 1 of 4
Healthy
Normal
Cached files are hits; pages come from the origin.
Step 1: Healthy
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Expecting HTML to be cached
majorEligibility follows the file extension. Pages are DYNAMIC until a rule includes them.
Wrongcf-cache-status: DYNAMICRightcache rule: /blog/*edge TTL 1 day, tag per postFlexible encryption
criticalVisitors see a lock, but the traffic to your server is plain HTTP.
Wrongmode = flexibleRightmode = full (strict)valid certificate on the originPurging everything on deploy
criticalEvery URL becomes a miss at once, and the origin carries the whole site.
Wrongpurge_everything: trueRightversioned filespurge tags for changed pagesLeaving the origin open
criticalAnyone who learns its address goes around every filter.
Wrongallow 0.0.0.0/0Rightallow Cloudflare ranges onlyor a tunnel
Interview tips
How to explain it
- One address, many cities.
- Filter, code, cache, tier, origin.
- Only misses cost the origin.
Calculate
- Origin load is traffic times each miss ratio.
- Batch purges: 100 operations a request.
- Compare plans by the limit you will hit first.
Reach for it when
- Readers are global.
- Origins are in several places.
- Security and code belong near the user.
Watch
- Hit ratio per content type.
- 522 and 524 counts.
- Purge failures.
- One provider, one shared failure.