Patterns

CDN push and pull

Put copies of your content on servers near users, either filling them on demand from your origin (pull) or uploading them yourself (push).

A CDN keeps copies of your responses at the edge, and pull and push differ in who puts them there.

Use it when#

  • Most traffic is pages, images, or video that many users share.

  • Users are far from your origin, and the round trip dominates latency.

  • Egress from your servers is a large part of the bill.

How it works#

With pull, the first request for a file misses, the edge fetches it from your origin, stores it for the TTL, and serves the next visitors itself. You do nothing to publish. With push, you upload files to the CDN yourself, which suits large files that change rarely, such as installers or video segments.

The cache key decides what counts as the same file. A key of path alone shares one copy among everyone and has the best hit ratio. A key that includes cookies keeps personal pages apart. A TTL of an hour raises hits and also lets old pages live for an hour, which is why deploys purge the cache.

What it costs#

A key that leaves out the cookie can show one user's page to another, and a long TTL without a purge serves yesterday's release. Pull also makes the first visitor to each file slow, and a purge sends a wave of misses back to the origin.

In Quorum#

Place a CDN after Content delivery and link it in front of the App Server. The game models pull only, so push is out of scope. Purge on deploy is the nearest control: a deploy empties the edge, and it refills from the origin.

Drag to pan. Hold Ctrl or Cmd and scroll to zoom.

At 3.00k Users the Simulation solves this Design to Apdex 0.98, p99 333 ms, 0.0% errors and $2.00/s Burn.
WhereSettingValueWhy
CDNTTL (seconds)3600An edge copy is reused for an hour before it asks the origin again, which raises the hit ratio and ages pages longer.
CDNPurge on deployOnA deploy clears the edge, so no visitor gets the old release. The edge then refills from the origin.
CDNCache keyqueryThe key holds the path and query string but not cookies, so more visitors share one copy. It is safe only while no cached page is personal.
App ServerInstance sizesmallSmall gives the app two vCPUs, enough to run code while the data tier does its own work.
DatabaseInstance sizesmallSmall gives the Database two vCPUs, so the figures below reflect the Cache and not a starved Database.

Research this Design needs: Content delivery.

The Cached page leak incident is the cache key mistake, and Edge-side includes is what makes a logged-in page cacheable at all. The glossary defines CDN.