CDN operations
medium 30 minRunning a CDN day by day: what to measure, when to wake somebody, how to keep attackers away, how to make it faster and cheaper, and how to find out why a user got a slow, stale or broken answer.
See it run
Read a dashboard, follow a request through the protection, find a stale copy, prepare for a peak and change a rule safely.
Operations
Reading the dashboard
Six points in time for four numbers. Example values.
Step 1 of 5
Hit ratio
| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| hit ratio | 89% | 91% | 92% | 93% | 94% | 94.5% |
| p95 ms | ||||||
| saved TB/day | ||||||
| 5xx rate |
94.5% of 95%
94.5%, rising, just below the target of 95%. Misses fell from 11% to 5.5%: half the origin load.
Step 1: Hit ratio
hit_ratio = hits / requests # target 95%p95 = percentile(latency_ms, 95) # target 50 mssaved = bytes_from_cache_per_day # target 2.0 TBerrors = count_5xx / requests # target 0.1%- When
- Every day
- You learn
- Trends
- Targets
- 95%, 50 ms, 2 TB, 0.1%
Translate the ratio into origin load before you relax.
In the real world
The same cdn operations doing real jobs. Pick one and step through it.
Eight locations.
Step 1 of 3
All healthy
| location | state | traffic |
|---|---|---|
| Tokyo | healthy | 100% |
| London | healthy | 100% |
| New York | healthy | 100% |
| Sydney | healthy | 100% |
| Frankfurt | healthy | 100% |
| Singapore | healthy | 100% |
| Sao Paulo | healthy | 100% |
| Mumbai | healthy | 100% |
8 of 8 healthy
Every check from outside succeeds.
Step 1: All healthy
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Alerting on the hit ratio alone
major95% to 90% looks small and doubles the origin's load.
Wrongalert_if(hit_ratio < 0.80)Rightalert_if(origin_rps > 0.6 * origin_capacity)warn_if(hit_ratio < 0.85)Blocking by user agent
majorAttackers choose any name. Real tools and crawlers are lost.
Wrongif "bot" in user_agent.lower(): return 403Rightif claims_crawler(user_agent) and not verified_by_dns(ip): challenge()Global rule at once
criticalA bad rule stops every user in every place within seconds.
Wrongrule.enable(percent=100)Rightrule.mode = "log" # then 1%, 25%, 100%Origin reachable around the CDN
criticalEvery protection at the edge can be skipped.
Wrongfirewall.allow("0.0.0.0/0", port=443)Rightrequire_client_certificate(ca="cdn")
Interview tips
How to explain it
- Wardens of mountain huts.
- Flags, a soup board, a gate, porters.
- A label on each bowl.
Memory trick: MOST
- Monitoring, Optimization.
- Security.
- Troubleshooting.
Targets to start with
- Hits above 90% for static files.
- p95 below 100 ms, 5xx below 0.1%.
- Origin below 20% of requests.
Debug order
- Hit or miss?
- Age and ETag?
- Which place, every place?