Part 7 of 8 · 2 min read
Trade-offs
What to say out loud.
Trade-offs and what to say
| Choice | Gain | Cost |
|---|---|---|
| More PoPs | Closer users | More cost and operations |
| Regional layer | Higher hit ratio | Extra hop on a miss |
| Origin shield | Origin protected | One more layer to run |
| DNS routing | Flexible and measurable | Resolver distance, DNS caching |
| Anycast | Automatic nearest and failover | Less control, route changes can break connections |
| Long TTL | High hit ratio, low cost | Stale content |
| Versioned URLs | No purge needed | The page that points to them must be fresh |
| Purge API | Immediate removal | Control plane complexity |
| Serve only popular items | Lower bill | Slower tail |
Interview angle
Answer in your head first, then open it.
How does a CDN speed things up?
It serves from a server near the user and spares the origin.
What if the file is not at the edge?
Ask the regional cache, then the shield, then the origin. Collapse repeats.
How do users reach the nearest edge?
DNS routing or anycast, with health checks.
How do you update a file?
Version the URL. Purge only when needed.
How do you control cost?
Cache only what is popular, raise the hit ratio, and use regional rules.
One follow-up to try. "Add live video." A good reply: segments of a few seconds are short-lived and requested by many viewers at once, so use short TTLs, request collapsing and a shield, and let edges pull from the packager. The origin must produce each segment once. Tune for latency over hit ratio history.
Check yourself: 1. Why is a regional layer useful? 2. When would you choose anycast? 3. What is special about live video segments?
Words you will meet
| Word | Meaning |
|---|---|
| Edge, PoP | A cache site close to users |
| Origin | The true source of the content |
| TTL | How long a copy may be used |
| Hit ratio | The share of requests served from cache |
| Purge | Removing content before it expires |
| Anycast | One address announced from many places |
| Request collapsing | Sending one upstream request for many identical ones |
| ETag | A tag that shows whether a file changed |