SyntaxPilot
Courses/System Design/Lesson 21

System Design · Lesson 21 of 40 · 10 min

Storage and CDNs

queued

These are the notes for System Design episode 21. ChaiNow's menu now shows a photo of every dish, and a photo vanishes just because a different app server answered. You'll move files out of the app servers, compare block, file and object storage, build a tiny object store (keys, bytes and metadata over HTTP, like Amazon S3), see what 11 nines of durability really means, watch photos crawl to London and New York and invent the CDN to fix it, then fix the CDN that keeps showing yesterday's price with max-age and versioned file names. Every demo is plain Python and runs as-is; outputs are real (Python 3.13). Distances are rounded straight-line figures (real cables are longer), and "3 round trips per photo" is a simplification; time in the cache demos is simulated (t in seconds), so the outputs never change.

The problems

Problem What it teaches
The photo vanished A local disk belongs to one machine; storage must live outside the app servers
Disk, folders or objects? Block, file and object storage
Millions of photos An object store: buckets, keys, metadata, HTTP PUT/GET; Amazon S3; durability and 11 nines
Slow in London Distance = latency; origin and edge; the CDN; cache hit and miss
Yesterday's price Stale copies at the edge; Cache-Control: max-age
Update instantly Versioned (hashed) file names; max-age=31536000, immutable; no-cache, no-store

Problem 1: the photo vanished

A cafe owner uploads a fresh photo of masala chai. The app server saves it, like any program would, as a file on its own disk. But since episode 6 ChaiNow runs three app servers behind a load balancer that hands requests out in turn. A customer opens the menu a second later, and a different server answers.

import os, itertools

# 3 app servers (episode 6), each with its OWN disk
for s in ["server1", "server2", "server3"]:
    os.makedirs(f"{s}/photos", exist_ok=True)
servers = itertools.cycle(["server1", "server2", "server3"])

def upload(name, data):              # the load balancer picks a server
    s = next(servers)
    with open(f"{s}/photos/{name}", "wb") as f:
        f.write(data)
    print("uploaded to", s)

def view(name):                      # ...and maybe a different one
    s = next(servers)
    print("viewing on", s)
    return open(f"{s}/photos/{name}", "rb").read()

upload("masala-chai.jpg", b"\xff\xd8 photo bytes")
view("masala-chai.jpg")

Output (the traceback's file paths shortened):

uploaded to server1
viewing on server2
Traceback (most recent call last):
  File "disks.py", line 20, in <module>
    view("masala-chai.jpg")
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "disks.py", line 17, in view
    return open(f"{s}/photos/{name}", "rb").read()
           ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'server2/photos/masala-chai.jpg'

The photo exists, just not on this machine. Each folder here stands for a separate server's disk. itertools.cycle hands out server1, server2, server3, server1 ... like a round-robin load balancer.

A local disk belongs to one machine. The moment you have more than one server, files can't live on any one of them. Storage has to live outside, somewhere every server can reach. (This is the same "keep app servers stateless" idea as episode 6.)

Problem 2: disk, folders or objects?

There are three kinds of storage.

Real life Storage type What it is
A blank notebook with numbered pages; you organise it Block storage A raw disk attached to one machine. It offers numbered fixed-size blocks; the program (or its file system) decides what goes where. Databases love it.
An office cupboard: shelves, folders, files, shared by the office File storage Folders and paths like /photos/a.jpg, shared over the network by many machines.
A railway cloakroom: hand in a bag, get a token, show the token, get the bag back Object storage Store bytes under a key, fetch them by that key, over HTTP. You never care which shelf. Huge, flat, cheap.

Block vs file vs object storage

Block File Object
You address data by Block number (via a disk device) Path in a folder tree Key in a flat bucket
Used by One machine at a time (usually) Many machines over the network Any number of clients over HTTP
Typical access Read/change small pieces in place, very fast Open, read, write files by path PUT a whole object, GET a whole object
Changing part of the data Yes, any block Yes, inside a file No: you replace the whole object
Metadata None (just bytes) File name, size, dates, permissions Any key-value metadata you attach (e.g. content type)
Scale One disk's size One shared file system Practically unlimited number of objects
Real-life example A notebook An office cupboard A railway cloakroom
Good for Databases, a server's operating system Shared documents, legacy apps that expect paths Photos, videos, backups, logs, static website files

Problem 3: millions of photos (an object store)

A bucket is one flat table: key to object. put stores the bytes with a little metadata (like the file type). get fetches by key. In real life those are HTTP PUT and HTTP GET requests. list_keys finds every key that starts with a prefix.

bucket = {}                          # one flat table: key -> object

def put(key, data, **meta):          # HTTP PUT  /chainow-photos/<key>
    bucket[key] = {"data": data, "meta": meta}

def get(key):                        # HTTP GET  /chainow-photos/<key>
    return bucket[key]["data"]

def list_keys(prefix):               # "folders" are just key prefixes
    return [k for k in bucket if k.startswith(prefix)]

# server 1 uploads...
put("dishes/masala-chai.jpg", b"\xff\xd8 chai", type="image/jpeg")
put("dishes/samosa.jpg", b"\xff\xd8 samosa", type="image/jpeg")
put("receipts/2026/10/order-42.pdf", b"%PDF receipt", type="application/pdf")

# ...server 2 reads: every server asks the same store
print(get("dishes/samosa.jpg"))
print(list_keys("dishes/"))
print(bucket["dishes/masala-chai.jpg"]["meta"])
print(len(bucket), "objects, 0 folders")

Output:

b'\xff\xd8 samosa'
['dishes/masala-chai.jpg', 'dishes/samosa.jpg']
{'type': 'image/jpeg'}
3 objects, 0 folders
  • Server 2 gets the samosa photo no matter which server uploaded it: every server asks the same store.
  • Listing dishes/ gives both dish photos.
  • 3 objects, 0 folders. dishes/samosa.jpg is just one long key; the slash only looks like a folder. Consoles show "folders" by grouping keys on their prefix.

A flat store of objects (each with a key, its bytes and its metadata), reached over HTTP, is object storage. You just invented object storage!

Amazon S3, the famous one

From the AWS News Blog post "Twenty years of Amazon S3 and building what's next":

Fact Quote
Launch "on March 14, 2006"
First price "The initial price was 15 cents per gigabyte"
Size today "Today, S3 stores more than 500 trillion objects"
Largest object "The maximum object size has grown from 5 GB to 50 TB"
Durability "Durability is designed for 11 nines (99.999999999%)"

What 11 nines means

Durability is "don't lose it": the chance that a stored object survives. 99.999999999% means a yearly loss chance of 0.000000001% per object. Store 10 million photos: 10,000,000 × 0.000000001% = 0.0001 objects lost a year, so on average about one photo every 10,000 years. (This arithmetic is ours, from the 11-nines figure.)

It gets there by replication: keeping copies on many machines (episode 11), so one dead disk loses nothing. Availability is a different promise: whether you can reach the data right now. A store can be extremely durable and still be briefly unreachable.

Problem 4: slow in London (the CDN)

ChaiNow opens cafes in London and New York, but all photos still live in one bucket in Mumbai. The place where the real file lives is the origin. From episode 4 (TeleGeography): light in fibre travels roughly 203,000 km/s, which works out to about 10 ms of round-trip delay per 1,000 km. London is about 7,200 km away, New York about 12,500 km.

MS_PER_1000_KM = 10                  # fibre: ~10 ms per 1,000 km, there and back
TRIPS = 3                            # connect + secure + ask for the photo
ORIGIN = "Mumbai"                    # where the storage bucket lives
KM = {("Mumbai", "London"): 7200, ("Mumbai", "New York"): 12500,
      ("Mumbai", "Mumbai"): 20, ("London", "London"): 20,
      ("New York", "New York"): 20}

def fetch_ms(user, server):
    return KM[(server, user)] * MS_PER_1000_KM / 1000 * TRIPS

edge_cache = {}                      # a copy kept in each city
def via_cdn(user, photo):
    if (user, photo) in edge_cache:
        return fetch_ms(user, user), "hit"
    edge_cache[(user, photo)] = True       # edge fetches once from Mumbai
    return fetch_ms(user, user) + fetch_ms(user, ORIGIN), "miss"

for user in ["Mumbai", "London", "New York"]:
    print(f"{user:<9} from Mumbai: {fetch_ms(user, ORIGIN):5.1f} ms")
for user in ["London", "London", "London", "New York"]:
    ms, kind = via_cdn(user, "samosa.jpg")
    print(f"{user:<9} via CDN:     {ms:5.1f} ms ({kind})")

Output:

Mumbai    from Mumbai:   0.6 ms
London    from Mumbai: 216.0 ms
New York  from Mumbai: 375.0 ms
London    via CDN:     216.6 ms (miss)
London    via CDN:       0.6 ms (hit)
London    via CDN:       0.6 ms (hit)
New York  via CDN:     375.6 ms (miss)
  • London: 7,200 km × 10 ms / 1,000 km = 72 ms per round trip, × 3 trips = 216 ms, per photo. A menu with 20 photos multiplies that pain.
  • Via the CDN, the first London customer still waits (a cache miss: the edge fetches from Mumbai once). Everyone after gets 0.6 ms (a cache hit, from a server 20 km away).
  • New York's first request is also a miss: each city's edge fills its own copy.

Copies of your files kept in data centres in many cities, so every user is served from nearby, form a content delivery network (CDN). The servers near users are edge servers. Cloudflare, for example, says: "95% of the world's Internet-connected population is within 50 milliseconds of a Cloudflare data center". You just invented the CDN!

The dairy and the milk booths

Milk in a city A CDN
One big dairy plant, where milk is packed Origin: the bucket in Mumbai
A milk booth on every street, stocked with copies Edge servers in many cities
Booth runs out? The truck refills it, only then Miss → fetch once from the origin, then hits for everyone

It's the cache from episode 7, spread across the planet. You can't make light faster, so you shorten the distance.

Problem 5: yesterday's price (stale copies)

The menu photo shows chai at Rs 20. The edge keeps its copy for max-age seconds (here 86,400, one day); after that it fetches a fresh copy. At second 60 the price goes up to Rs 25.

origin = {"/menu.jpg": "chai Rs 20"}      # the file in storage
edge = {}                                 # the CDN's copy: url -> (body, saved_at)
MAX_AGE = 86400                           # Cache-Control: max-age=86400 (1 day)

def cdn_get(url, now):                    # now = time in seconds
    if url in edge and now - edge[url][1] < MAX_AGE:
        return edge[url][0] + "   (edge copy)"
    edge[url] = (origin[url], now)        # missing or too old: fetch again
    return origin[url] + "   (fresh from origin)"

print("t=0     ", cdn_get("/menu.jpg", 0))
origin["/menu.jpg"] = "chai Rs 25"        # price changed at t=60
print("t=120   ", cdn_get("/menu.jpg", 120))
print("t=86400 ", cdn_get("/menu.jpg", 86400))

# fix: a new name for every new version (a hash of the content)
origin["/menu.3f9a1c.jpg"] = "chai Rs 25"
print("t=120   ", cdn_get("/menu.3f9a1c.jpg", 120))

Output:

t=0      chai Rs 20   (fresh from origin)
t=120    chai Rs 20   (edge copy)
t=86400  chai Rs 25   (fresh from origin)
t=120    chai Rs 25   (fresh from origin)
  • At t = 120 the edge still shows Rs 20: its copy is fresh by its own rules (120 < 86,400). Only after a full day does it fetch Rs 25. A whole day of the wrong price.
  • A copy far away doesn't know the original changed: it has gone stale (the stale data problem from episode 7).
  • A shorter max-age? Then more misses, and more slow trips to Mumbai. It's a trade-off.
  • The clever fix (last two lines): never change a file. Give every new version a new name with a short hash of its content, like menu.3f9a1c.jpg. The page links to the new name; the edge has never seen it, so it fetches it fresh, instantly. This is cache busting with a versioned file name.

Problem 6: cache forever, update instantly (Cache-Control)

The origin tells every cache what to do with the Cache-Control response header:

# the HTML page: changes often, check every time
Cache-Control: no-cache

# /assets/menu.3f9a1c.jpg: the name changes with the content
Cache-Control: max-age=31536000, immutable

# a customer's receipt: never keep a copy anywhere
Cache-Control: no-store

What MDN says about each directive:

Directive MDN Use it for
max-age=N "the response remains fresh until N seconds after the response is generated" Anything you may reuse for a while
s-maxage=N "how long the response remains fresh in a shared cache" (overrides max-age for CDNs and proxies) Different freshness for the CDN than for browsers
immutable "the response will not be updated while it's fresh" Versioned (hashed) files
no-cache A cache may store it but must check with the origin before every reuse (textbook meaning) The HTML page that links to the hashed files
no-store "any caches of any kind (private or shared) should not store this response" Receipts, account pages, private data
public Lets the response be stored in a shared cache Truly public files only

For versioned assets MDN recommends: "You can add a long max-age value and immutable because the content will never change", with Cache-Control: max-age=31536000, immutable. 31,536,000 seconds = 365 days, one year.

The full pattern: hashed asset names cached for a year + an HTML page with no-cache that always points to the newest names. Cache forever, still update instantly.

The whole chain

  1. Own disks → FileNotFoundError on server 2 → storage outside the app servers.
  2. Block (a notebook), file (a cupboard), object (a cloakroom).
  3. Object store: key → bytes + metadata, over HTTP (Amazon S3, 11 nines via replication).
  4. Far users wait (216 / 375 ms per photo) → CDN edges: miss once, then hits (0.6 ms).
  5. Edge shows the old price → max-age decides how long a copy stays fresh.
  6. New name per version (hash) + max-age=31536000, immutable; HTML no-cache; private data no-store.

Common mistakes (and the real errors)

Mistake Code Error / result Fix
Saving uploads to the app server's own disk open(f"{server}/photos/{name}") FileNotFoundError: [Errno 2] No such file or directory: 'server2/photos/masala-chai.jpg' Object storage every server can reach
Changing a file but keeping its name Cache-Control: max-age=86400 on /menu.jpg t=120 chai Rs 20 (edge copy) Hash in the name, max-age=31536000, immutable
Letting shared caches keep private data Cache-Control: public on a receipt MDN: public lets it be stored in a shared cache no-store for private data
Treating keys like case-insensitive paths get("dishes/Samosa.jpg") KeyError: 'dishes/Samosa.jpg' Keys are exact strings: build them in one place
A long max-age on the HTML page max-age=31536000 on /menu.html the page keeps linking to old hashed names no-cache on HTML, long max-age only on hashed files
A database on object storage PostgreSQL files in a bucket every small change rewrites a whole object A block disk attached to the database machine

Mini project: a tiny object store with hashed names and an edge cache

put names each object by a short SHA-256 hash of its content and stores its Cache-Control header as metadata; edge_get is a CDN edge that reads max-age, counts hits and misses, and never keeps a no-store object.

# Mini project: a tiny object store with hashed names + an edge cache that obeys Cache-Control
import hashlib

store = {}                                  # the origin bucket: key -> object

def put(name, data, cache_control):         # HTTP PUT
    digest = hashlib.sha256(data).hexdigest()[:6]
    base, ext = name.rsplit(".", 1)
    key = f"{base}.{digest}.{ext}"          # versioned name: changes with the content
    store[key] = {"data": data, "Cache-Control": cache_control}
    return key

def max_age(cache_control):                 # "max-age=31536000, immutable" -> 31536000
    for part in cache_control.split(","):
        part = part.strip()
        if part == "no-store":
            return None                     # never keep a copy
        if part.startswith("max-age="):
            return int(part.split("=")[1])
    return 0

edge = {}                                   # the CDN's copies: key -> (object, saved_at)
stats = {"hit": 0, "miss": 0}

def edge_get(key, now):                     # HTTP GET at the edge
    if key in edge:
        obj, saved = edge[key]
        if now - saved < max_age(obj["Cache-Control"]):
            stats["hit"] += 1
            return obj["data"], "hit"
    obj = store[key]                        # miss: one trip to the origin
    stats["miss"] += 1
    if max_age(obj["Cache-Control"]) is not None:
        edge[key] = (obj, now)
    return obj["data"], "miss"

v1 = put("menu.jpg", b"chai Rs 20", "max-age=31536000, immutable")
r = put("order-42.pdf", b"receipt for Asha", "no-store")
print("v1 key:", v1)
for t in [0, 10, 20]:
    print(f"t={t:<3}", *edge_get(v1, t))

v2 = put("menu.jpg", b"chai Rs 25", "max-age=31536000, immutable")
print("v2 key:", v2)                        # new content -> new name
for t in [30, 40]:
    print(f"t={t:<3}", *edge_get(v2, t))

for t in [50, 60]:
    print(f"t={t:<3}", *edge_get(r, t), "(no-store)")
print(stats, "| copies at the edge:", len(edge))

Output:

v1 key: menu.0c4be5.jpg
t=0   b'chai Rs 20' miss
t=10  b'chai Rs 20' hit
t=20  b'chai Rs 20' hit
v2 key: menu.8593a1.jpg
t=30  b'chai Rs 25' miss
t=40  b'chai Rs 25' hit
t=50  b'receipt for Asha' miss (no-store)
t=60  b'receipt for Asha' miss (no-store)
{'hit': 3, 'miss': 4} | copies at the edge: 2
  • The new price gets a new key (menu.8593a1.jpg), so it's served fresh at once, even though v1 is cached for a year.
  • The receipt is a miss every time: no-store means the edge never keeps it, so only the menu versions are at the edge.
  • Extend it: support s-maxage (prefer it over max-age at the edge), and add a list_keys(prefix) like the OBJECTS demo.

Practice

  1. Homework: add a Singapore customer to the CDN demo, about 3,900 km from Mumbai. What prints?
  2. Homework: in the STALE demo, set MAX_AGE = 60. What changes?
  3. Homework: in the OBJECTS demo, list receipts/2026/. And what does list_keys("dish") return?
  4. Comment: what on ChaiNow should never be cached?
  5. With 11 nines, how many objects would you expect to lose per year out of 1 billion?
  6. Which storage type fits each: a server's operating system disk, nightly database backups, a folder of shared invoices that an old accounting app opens by path?
  7. Why put no-cache on the HTML page but max-age=31536000, immutable on the images it links to?
Solutions and hints

1. Add ("Mumbai", "Singapore"): 3900, ("Singapore", "Singapore"): 20 to KM, "Singapore" to the first loop, and "Singapore", "Singapore" to the second:

Mumbai    from Mumbai:   0.6 ms
London    from Mumbai: 216.0 ms
New York  from Mumbai: 375.0 ms
Singapore from Mumbai: 117.0 ms
London    via CDN:     216.6 ms (miss)
London    via CDN:       0.6 ms (hit)
London    via CDN:       0.6 ms (hit)
New York  via CDN:     375.6 ms (miss)
Singapore via CDN:     117.6 ms (miss)
Singapore via CDN:       0.6 ms (hit)

3,900 km × 10 / 1,000 × 3 = 117 ms from Mumbai; the second Singapore customer gets a hit.

2.

t=0      chai Rs 20   (fresh from origin)
t=120    chai Rs 25   (fresh from origin)
t=86400  chai Rs 25   (fresh from origin)
t=120    chai Rs 25   (fresh from origin)

At t = 120 the copy is 120 s old, more than 60, so the edge fetches again and shows Rs 25. The price is right, but every request after a minute is a slow trip to the origin: fewer stale answers, more misses.

3. Add print(list_keys("receipts/2026/")) and print(list_keys("dish")); the two extra lines print:

['receipts/2026/10/order-42.pdf']
['dishes/masala-chai.jpg', 'dishes/samosa.jpg']

"dish" matches too: a prefix is plain string matching, not a folder name. End prefixes with / when you mean "folder".

4. Anything private or per-person: receipts, order history, account and payment pages, login responses (no-store). Also be careful with anything that must be live, like the "cafe open now" status or stock levels (short max-age or no-cache).

5. 1,000,000,000 × 0.000000001% = 0.01 objects a year, about one object every 100 years.

6. OS disk: block. Backups: object (big whole files, written once, read rarely, cheap). Shared invoices for an app that expects paths: file storage.

7. The HTML must always be checked so it points to the newest hashed names. The images never change under their name (a new version gets a new name), so caching them for a year is safe and makes nearly every request a hit.

Quick quiz

# ChaiNow needs to store:
#  1. 50 million dish photos, read by everyone
#  2. its PostgreSQL database files

# Which pair fits best?
  • A. 1: block, 2: object
  • B. 1: object, 2: block
  • C. Both: object
  • D. Both: file
Answer

B. Photos are whole files fetched by key, millions of them: object storage. A database constantly reads and changes small parts of its files, so it wants a block disk attached to its own machine.

Interview questions

  • Why shouldn't app servers store uploads on their local disk? (More than one server: the file is on one machine only; servers become stateful; a dead server loses files.)
  • Block vs file vs object storage: when do you use each? (Databases and OS disks; shared paths; huge numbers of whole files over HTTP.)
  • How do "folders" work in an object store? (They don't exist: keys with / in them, listed by prefix.)
  • What is the difference between durability and availability? (Not losing data vs being able to reach it right now.)
  • How does an object store reach 11 nines? (Replication: many copies on many machines and disks, repaired when one fails.)
  • Design photo upload for an app: where does the file go, where does the database row go? (Bytes in object storage under a key; the key and metadata in the database; served through a CDN.)
  • What is a CDN and why does it help? (Copies at edge servers near users; latency is set by distance; fewer requests reach the origin.)
  • What happens on a cache miss at the edge? (The edge fetches from the origin once, stores it per Cache-Control, then serves hits.)
  • How do you update a file that the CDN has cached? (Versioned/hashed file names; or wait for max-age; or ask the CDN to purge it.)
  • no-cache vs no-store? (Store but revalidate every time vs never store at all.)
  • max-age vs s-maxage? (All caches vs shared caches like CDNs only.)
  • What must never be cached in a shared cache? (Private, per-user responses: use no-store, never public.)

Glossary

Term Meaning
Storage Where data lives when no program is holding it in memory
Local disk A disk inside (or attached to) one machine; other machines can't read it
Stateless server An app server that keeps no files or sessions of its own, so any server can answer
Block storage A raw disk offered as numbered fixed-size blocks to one machine; the program or file system decides what goes where
File storage Files in a folder tree with paths, shared over the network by many machines
Object storage A flat store of objects, each with a key, its bytes and metadata, reached over HTTP
Bucket A named container of objects in an object store, e.g. chainow-photos
Key The unique name of an object in a bucket, e.g. dishes/samosa.jpg
Object The stored item: its bytes (data) plus metadata, found by its key
Metadata Data about the data, e.g. content type image/jpeg, size, Cache-Control
Prefix The start of a key; listing by prefix is how object stores show "folders"
Amazon S3 Amazon Simple Storage Service, AWS's object store, launched 14 March 2006
Durability The chance stored data is not lost
Availability The chance the data can be reached right now
Replication Keeping copies of data on several machines so one failure loses nothing
11 nines 99.999999999%: S3's designed durability; about 1 lost object per 10,000 years out of 10 million
Origin The server or bucket where the real file lives
Edge (edge server) A CDN server in a city near users that keeps copies of files
CDN (content delivery network) Many edge servers in many cities serving copies of your files from near each user
Cache A store of copies kept so later requests are answered faster
Cache hit The cache already has a fresh copy and answers itself
Cache miss The cache has no fresh copy and must fetch from the origin
Shared cache A cache used by many users, such as a CDN or proxy (a browser's cache is private)
Latency The delay before a response arrives
Round trip A message going to a server and the reply coming back; in fibre about 10 ms per 1,000 km
Fibre (optical fibre) Glass cables carrying data as light, roughly 203,000 km/s
ms (millisecond) One thousandth of a second
HTTP The protocol web browsers, apps and servers use to request and send data
HTTP PUT A request that stores (uploads or replaces) the data at a URL or key
HTTP GET A request that fetches the data at a URL or key
HTTP header A Name: value line sent with a request or response, e.g. Cache-Control
Cache-Control The HTTP header that tells browsers and CDNs whether and how long to keep a response
max-age Directive: the response stays fresh for N seconds after it is generated
s-maxage Directive: how long the response stays fresh in a shared cache (CDN/proxy)
no-cache Directive: may be stored, but must be checked with the origin before every reuse
no-store Directive: no cache of any kind may store the response
public Directive: the response may be stored in a shared cache
immutable Directive: the response will not be updated while it's fresh, so don't recheck it
Fresh A cached copy still within its max-age, used without asking the origin
Stale A cached copy that is too old, or no longer matches the original
Cache busting Forcing caches to fetch a new version, usually by changing the file's name or URL
Versioned file name A file name containing a version or hash, e.g. menu.3f9a1c.jpg, that changes whenever the content does
Hash A short fingerprint computed from content (e.g. SHA-256); different content gives a different hash
Purge (invalidation) Asking a CDN to drop its cached copy of a URL before max-age runs out
FileNotFoundError Python's error when opening a file that doesn't exist at that path
KeyError Python's error when a dictionary has no such key

Summary

  • A local disk belongs to one machine; with many app servers, files must live in shared storage outside them.
  • Block storage is a raw disk (databases), file storage is shared folders and paths, object storage is key → bytes + metadata over HTTP (photos, backups).
  • In an object store, "folders" are just key prefixes; Amazon S3 is designed for 11 nines of durability through replication.
  • Distance sets latency (~10 ms per 1,000 km round trip): a CDN keeps copies at edges near users, one miss, then hits.
  • Edge copies go stale; max-age decides for how long.
  • Give every version a new hashed name, cache it with max-age=31536000, immutable, serve the HTML with no-cache, and private data with no-store.

Next episode: a customer types "masala" into the search box. A million dishes: how do you find the matches in milliseconds? Search, and the inverted index.

Sources: AWS News Blog, "Twenty years of Amazon S3 and building what's next"; Cloudflare network map page; MDN Web Docs, "Cache-Control"; TeleGeography (light in fibre, as used in episode 4).