Part 4 · Blueprint 21
CDN Architecture, Anycast & Edge Compute
14 min reading · Sources · Editorial review pending
An edge copy can outlive a withdrawal unless its freshness contract is explicit.
Page details
Published date · Last edited:
Draft edition. Editorial review and supplementary reading recommendations are still being completed.
Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Latency Numbers & Networking Foundations, Distributed Caching & Stampede Prevention.
Sixty-second mental model
Problem: An edge copy can outlive a withdrawal unless its freshness contract is explicit.
Use: Separate routing, origin shielding and cache validity.
Design boundary: Move cacheable representations closer to readers while preserving correct keys, expiry and origin protection. A CDN is not a generic replacement for authorized application state. Separate immutable versioned assets from mutable entry points.
Layer 1 · Intuition
Hypothetical scenario: Northwind is designing content delivery networks. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one object request means and which component owns the origin version.
Think of regional pickup depots backed by a warehouse. Separate the requester from origin version, then identify the retained evidence needed after failure.
- Authority
- The entitled state owner.
- Invariant
- A rule preserved across concurrency and failures.
- Anycast
- Routing the same destination address to one of multiple announcing network locations. Analogy: One service address reachable through several regional entrances.
- CDN
- Content delivery network: distributed delivery infrastructure that serves content closer to clients under cache and routing rules. Analogy: Local pickup depots reducing trips to the central warehouse.
Architecture and worked reasoning
Design boundary: Move cacheable representations closer to readers while preserving correct keys, expiry and origin protection. A CDN is not a generic replacement for authorized application state. Separate immutable versioned assets from mutable entry points.
Responsibilities on the request path
Workload and limiting resource
Hypothetical video asset demand is 10,000 requests/s at 200 KB/segment: 2,000,000 KB/s, or 2 GB/s in decimal units. At 95% edge hits, normal origin segment demand is 500 requests/s and 100 MB/s. A regional cold cache can change both numbers; size and admit the refill path separately.
Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.
Mutation or publication path
- Publish immutable versioned bytes.
- Update the selected manifest or mutable pointer.
- Invalidate only where necessary and retain referenced versions.
Observation and recovery path
- Construct a key including relevant representation dimensions.
- Serve an eligible cached object or coalesce a permitted origin fetch.
- Validate current access at the appropriate boundary for private content.
Failure that changes the decision
Hypothetical scenario: A cache key omits tenant identity or an authorization-dependent variant. One customer receives another customer’s cached representation; TTL reduction does not repair the isolation error.
Attempt this decision before reading the explanation
Does purging an asset instantly remove every copy already downloaded by clients?
No. Purging affects caches under the purge contract, not bytes already held by clients. Use authorization, versioning and retention/revocation semantics appropriate to the content.
Supporting mechanism analysis
Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.
Hypothetical scenario. Many promotion visitors request the same public product page. Dev proposes serving saved responses from the edge. Maya switches the example visitor’s market and asks whether that saved price is still the answer the visitor requested.
The next design decision is eligibility for reuse. Follow one representation through its identity, age and delivery, then calculate the work that an assumed hit rate avoids. A quick response from the wrong market does not satisfy the catalogue brief.
Before you continue: Does a short cache lifetime make a response eligible for every visitor?
Lifetime alone does not establish that market, currency or other answer-changing dimensions match. A young response can still answer the wrong request.
This preserves both meaning and freshness. The origin-demand calculation becomes useful only after the reuse contract identifies which hits are acceptable.
A content delivery network places serving capacity near users and can reuse stored responses. The origin remains responsible for producing the authoritative representation under Northwind’s application rules. An edge hit avoids some origin work, but the response is acceptable only if it matches the requested product, market, currency and other relevant dimensions.
A cache key identifies the stored representation selected for reuse. Northwind’s public catalogue contract has no private visitor fields, but it does include market and currency. If these change the answer, the cache policy must distinguish them. Ignoring a dimension can return a technically fresh response for the wrong request.
HTTP caching provides standard controls for storage and reuse. RFC 9111 defines freshness, validation and the role of fields such as Vary. Use the origin’s representation contract to decide the relevant dimensions, then choose how the selected CDN expresses them. Do not assume every request header automatically becomes part of a cache key.
Public product information can be a candidate for shared reuse. Account details, tenant-specific prices or access-controlled records require a different decision. Encrypting the connection does not make a shared cache entry private. A cache key that merely contains a product identifier does not distinguish two callers with different permissions.
Hypothetical scenario. A source representation is already thirty seconds old when stored at an inner cache. It spends ten seconds there, eight more at an edge cache and two in delivery. The selected source-evidence age is 30 + 10 + 8 + 2 = 50 seconds. Creating a new edge response must not restart that evidence clock. HTTP response age and application-specific price evidence are related observations with different definitions.
Choose a key containing every dimension that changes the reusable result: product, market, currency and representation version in this example. Personalized or permission-dependent content also needs an explicit sharing rule. An ETag validates a selected representation; it is not a universal authorization or source-freshness certificate.
Versioned immutable assets avoid overwriting cached bytes under one name, but the pointer selecting the active asset still changes. Collapse simultaneous eligible misses only within a compatible key and authority scope. A withdrawal needs a propagation or current-check rule whose bound is part of the product contract; an ordinary cache lifetime cannot promise instantaneous revocation.
Hypothetical worked example. Keep the selected fifteen catalogue reads per second. Suppose an illustrative interval has twelve eligible edge hits and three misses each second, with each miss producing one origin request. The hit share is 12 ÷ 15 = 0.8, or 80%. Origin demand is 15 × (1 − 0.8) = 3 reads per second.
Using the selected 2,000-byte response, payload sent from the edge to visitors is still 15 × 2,000 = 30,000 bytes per second. Origin-to-edge payload for those misses is 3 × 2,000 = 6,000 bytes per second. The difference is 30,000 − 6,000 = 24,000 bytes per second in this simplified accounting. Headers, validation, retries and other objects are excluded.
This is a selected hit pattern, not a promised cache ratio. If a new deployment changes every representation key, the cache can be cold. At zero hits, origin demand returns to fifteen reads per second. Retain the original capacity argument rather than sizing the origin only for the warm-cache average.
Northwind’s sixty-second rule concerns the age of the price evidence when delivered. HTTP freshness concerns how a stored response may be reused under its caching policy. Those clocks need not start together. An origin can generate a new HTTP response around a product record that was already old.
Choose a product record already forty-five seconds old when the edge stores its response. After twenty seconds in the edge cache and a further one second to deliver and present, its selected evidence age is 45 + 20 + 1 = 66 seconds. A thirty-second cache lifetime would not prevent this result, even though the response spent only twenty seconds in that cache.
Under those selected assumptions, the remaining allowance before the sixty-second limit is 60 − 45 − 1 = 14 seconds at storage time. That arithmetic suggests an application-aware limit or revalidation decision; it does not make a fourteen-second setting universally correct. Upstream lag, clock interpretation and delivery variation must be accounted for in the real contract.
Validation asks an origin whether a stored representation remains suitable, using protocol mechanisms such as validators. It can reduce transferred payload when unchanged, but still involves communication and origin-side work. A validation response does not automatically establish an application fact that the origin never checked.
Versioned immutable asset names are useful for resources whose contents truly do not change under that identity. A product price at a stable URL is a different object. Updating a price may require expiry, validation or an invalidation mechanism. State which caches are reached and what happens during propagation rather than promising that a purge immediately changes every response a visitor can see.
Do not use an old value during origin failure unless the application contract explicitly permits it. A stale picture may be acceptable where a stale promotion price is not. Availability and freshness are product decisions attached to the representation, not one global caching switch.
RFC 9111 is a real primary contract for HTTP caching. Its distinction between storing a response, considering it fresh and validating it is useful precisely because those are separate decisions. Northwind adds its own product-age and identity rules on top. A CDN deployment should be checked against both layers.
Layer 3 · Internals
Trade-offs and limits
| Approach | Provides | Requires |
|---|---|---|
| Edge cache reuse | Can reduce origin work and distant transfer for eligible content. | Freshness, invalidation and origin shielding require a policy. |
| Direct origin fetch | Uses the current origin path for every request. | Origin and network capacity carry the full demand and failure exposure. |
Recovery decision
Hypothetical scenario: A cache key omits tenant identity or an authorization-dependent variant. One customer receives another customer’s cached representation; TTL reduction does not repair the isolation error.
No. Purging affects caches under the purge contract, not bytes already held by clients. Use authorization, versioning and retention/revocation semantics appropriate to the content.
Write your design before revealing the review
Does purging an asset instantly remove every copy already downloaded by clients?
Drafts and self-review are stored only in this browser. They are separate from reading completion.
Compare your decision
No. Purging affects caches under the purge contract, not bytes already held by clients. Use authorization, versioning and retention/revocation semantics appropriate to the content.
A cache key omits tenant identity or an authorization-dependent variant. One customer receives another customer’s cached representation; TTL reduction does not repair the isolation error.
Check your understanding
Does purging an asset instantly remove every copy already downloaded by clients?
No. Purging affects caches under the purge contract, not bytes already held by clients. Use authorization, versioning and retention/revocation semantics appropriate to the content.
How would you recover from this failure: A cache key omits tenant identity or an authorization-dependent variant. One customer receives another customer’s cached representation; TTL reduction does not repair the isolation error.
Start with the exact boundary that failed. Publish immutable versioned bytes. Update the selected manifest or mutable pointer. Invalidate only where necessary and retain referenced versions. Then recover evidence through the observation path: Construct a key including relevant representation dimensions. Serve an eligible cached object or coalesce a permitted origin fetch. Validate current access at the appropriate boundary for private content. Preserve the distinction between a confirmed state change and an unavailable response.
Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?
Hypothetical video asset demand is 10,000 requests/s at 200 KB/segment: 2,000,000 KB/s, or 2 GB/s in decimal units. At 95% edge hits, normal origin segment demand is 500 requests/s and 100 MB/s. A regional cold cache can change both numbers; size and admit the refill path separately. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Move cacheable representations closer to readers while preserving correct keys, expiry and origin protection. A CDN is not a generic replacement for authorized application state. Separate immutable versioned assets from mutable entry points.
Which component in this topology could be removed from a smaller first deployment?
Viewer, Edge cache, Origin shield, Asset origin name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Publish immutable versioned bytes.
What evidence must a caller have before relying on the observation path?
Construct a key including relevant representation dimensions. Serve an eligible cached object or coalesce a permitted origin fetch. Validate current access at the appropriate boundary for private content. No. Purging affects caches under the purge contract, not bytes already held by clients. Use authorization, versioning and retention/revocation semantics appropriate to the content.
45-minute interview rubric
- 00–05: scope object request and origin version.
- 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
- 12–28: draw origin version, numbered writes and reads.
- 28–40: challenge recovery: Separate routing, origin shielding and cache validity.
- 40–45: defend object_key placement, observations and remaining assumptions.
Go deeper
- RFC 9111: HTTP Caching · Primary document · www.rfc-editor.org. Separate routing, origin shielding and cache validity. Verified 2026-10-26.
Decision log
Separate routing, origin shielding and cache validity.
Preserve object request identity and origin version ownership.
Revisit changed workload, observations or recovery objectives.