Skip to content

Volume ITechnology

13.4 — Object Storage, CDNs and the Edge ​

Object storage is the cloud service that keeps files of any size and hands them back over the web. Amazon's is called S3, Azure's is Blob Storage and Google's is Cloud Storage. A stored file is called an object, and the container you put objects in is called a bucket. You store an object by sending a web request of the kind called PUT (Chapter 5.6).

Here is an upload that works for every test file and fails on a 6 GB video:

EntityTooLarge: Your proposed upload exceeds the maximum allowed size

A single PUT to Amazon S3 is capped at 5 GB. The object itself can be far larger — up to 50 TB since December 2025, when AWS raised the limit from 5 TB. You just cannot send it in one request. The fix is a multipart upload, which sends the file in pieces. Section 4 shows how. It has three more benefits. You can resume it after a failure, you can send several pieces at the same time, and it finishes sooner.

Object storage looks like the folders and files on your laptop, but it works differently. Most of the surprises on this page come from that difference.

1. Object storage is a flat key-value store ​

A key-value store keeps each piece of data under a name. You give the name, called the key, and you get the data back, called the value. Object storage is exactly that. The key is a piece of text and the value is the file.

There are no folders. photos/2026/08/cat.jpg looks like a file inside three folders. It is one key that happens to contain slashes. The store is flat: every object sits side by side in the bucket.

The console shows folders anyway. It splits each key at the / characters and groups the results, only to make the list easier to read. Because the folders are not real, four things work differently from your laptop.

You cannot rename an object. To change a key, you copy the object to the new key and delete the old one. The first part of a key, such as photos/2026/, is called a prefix. "Renaming a folder" therefore means copying and deleting every object whose key starts with that prefix. For a million objects that is a long-running job.

You cannot add to the end of an object, and you cannot change part of it. You can only replace the whole object. So a log file that grows line by line cannot live in object storage as one growing object.

Listing is slow. On your laptop, opening a folder is quick. Here, a listing has to search for every key that starts with a given prefix. The answer comes back one page at a time, usually a thousand keys per page. So never list a bucket of ten million objects to find one of them. Either build the key from something you already know, such as the user's ID, or keep a table of keys in a database.

What you read is up to date, with one exception. Since 2020, the major providers promise this: once a write has finished, the very next read returns the new object. This promise is called strong consistency. A listing may still be a moment behind. So a program that writes some objects and then immediately lists the bucket to find them can miss a few. Pass the keys along in your program. Do not list to find out what you just wrote.

2. Durability, availability, and what neither protects ​

Durability answers the question "will my bytes still exist next year?" Providers promise "eleven nines", which is 99.999999999%. Put another way, if you store ten million objects, you should expect to lose one about every ten thousand years. They achieve this with a technique called erasure coding. Each object is cut into fragments. Some extra fragments are calculated from them, in such a way that any lost fragment can be worked out again from the others. All the fragments are then spread over several zones. A few disks, or even a whole zone, can be lost and the object can still be rebuilt.

Availability answers a different question: "can I reach my object right now?" Providers promise about 99.9% to 99.99% here. That is far lower than the durability figure. It allows for up to a few hours a year when the service cannot be reached, even though nothing is lost. Advertising often blurs these two numbers together. Keep them apart.

Neither number protects you from your own actions. If you delete an object, the store deletes it, reliably. The same goes for overwriting it, for a faulty script, and for ransomware, which is an attack that scrambles your files and demands payment to unscramble them. Three controls protect against these.

  • Versioning. With versioning turned on, an overwrite does not destroy the old object. The old one is kept as an earlier version. A delete only adds a marker that says "deleted", and the versions stay underneath. So you can get the old data back.
  • Object lock. You set a period, for example one year, during which an object can be read and cannot be changed or deleted. This is also called write-once-read-many. Not even an administrator can delete a locked object. So it still protects you when an attacker has stolen an administrator's password. It is the way to keep backups safe from ransomware.
  • Replication to another account or region. A second copy is kept somewhere that a break-in to your main account does not reach.

Versioning has a cost that people forget. You pay for every old version. Section 3 describes lifecycle rules, which can delete old versions automatically. Without such a rule, a bucket whose objects are rewritten often grows for ever. Nobody notices, because a normal listing shows only the current versions and looks small.

3. Storage classes ​

ClassForRetrieval
StandardFrequently accessedImmediate
Infrequent accessMonthly-ishImmediate, per-GB retrieval fee
One-zone infrequentReproducible dataImmediate, lost if the zone is lost
Archive / GlacierRare accessMinutes to hours
Deep archiveCompliance, yearsUp to 12 hours

A storage class, also called a tier, is a price plan for an object. The cheaper it is to keep an object in a class, the more it costs, and the longer it takes, to get the object back out.

Pay attention to the retrieval fee and the retrieval time. The archive classes cost very little per month. Reading from them is expensive and slow. Suppose a rule moved an old dataset into deep archive, and a year later a project needs it. Getting it back can cost far more than the archive ever saved, and the team waits half a day for it. So move data to a cheaper class because you have measured that nobody reads it. Do not move it only because it is old.

Intelligent tiering does the measuring for you. The provider watches how often each object is read and moves it between classes automatically. It charges a small monitoring fee for each object. This is the right choice when you do not know how your data will be used. It is the wrong choice for a bucket of millions of tiny objects, because the fee per object adds up to more than the saving.

A lifecycle rule is an instruction the store carries out on its own as objects age. Examples are "move to infrequent access after 30 days" and "delete after one year". There is one rule that every bucket should have and most do not: delete multipart uploads that were never finished. When a 6 GB upload fails halfway, the pieces already sent stay in the bucket. You are charged for them. They do not appear in a normal listing. They stay for ever. This is one of the most common hidden costs in the cloud, and one three-line rule removes it.

4. Performance ​

How many requests a bucket can serve each second depends on how your keys begin. Behind the scenes the store divides a bucket's keys among many servers, and it divides them by prefix. Each share is called a partition. One prefix can serve thousands of requests a second. If your keys are spread across many prefixes, the store spreads them across many partitions, and the total rises. Now suppose every key begins with today's date. All of today's requests go to the same partition, and that one partition is overloaded while the others sit idle. Chapter 7.5.2 called this a hot partition. The cure is to put something that varies at the front of the key. Write a7f3/2026-08-02/... and not 2026-08-02/a7f3/....

A multipart upload cuts an object into parts. The parts are uploaded separately, several at a time, and the store joins them back together at the end. You must use it above 5 GB. It is worth using above about 100 MB. Sending parts side by side is faster. And when one part fails, you send only that part again.

The part rules decide the part size. On S3, each part except the last must be at least 5 MB and at most 5 GB, and one upload can have at most 10,000 parts. Work it through for a 6 GB video. With 100 MB parts you send 60 parts. If part 37 fails, you resend 100 MB, not 6 GB. For a 2 TB file, 10,000 parts means each part must be at least 200 MB, so the part size has to grow with the file.

Conditional writes stop two uploads overwriting each other. Since 2024, S3 accepts a PUT with the header If-None-Match: *. It means "write this only if no object with this key exists yet". If two workers race to create invoices/2026/0042.pdf, the first succeeds and the second gets 412 Precondition Failed, instead of silently replacing the first file. Azure Blob Storage and Google Cloud Storage have offered the same kind of check for longer. It is the storage version of the idempotency rule in Chapter 10.4.

A byte-range request fetches only part of an object. You ask for, say, bytes 1,000,000 to 2,000,000. This is how a video player jumps to the middle of a film without downloading the first half. Analytics tools use it too. They read only the columns they need out of a large data file and leave the rest (Chapter 7.8.1).

Server-side filtering lets the store search inside an object for you. You send a query, written in the database language SQL, and the store returns only the rows that match. The filtering happens where the data lives, so far less data crosses the network.

Transfer acceleration speeds up uploads from far away. The upload goes first to an edge location near the user. From there it travels over the provider's own private long-distance network, called its backbone, which is faster and steadier than the public internet.

5. Pre-signed URLs ​

Suppose a user wants to upload a photo. The obvious design sends the photo to your application, and your application passes it on to storage. Every byte then travels through your servers.

A pre-signed URL avoids that. Your application creates a special web address for one particular object. The address contains a signature that proves your application approved it, and it stops working after a short time. You give that address to the user's browser, and the browser sends the photo straight to storage. Use this for user uploads and downloads unless you have a reason not to.

ts
const url = await getSignedUrl(s3, new PutObjectCommand({
  Bucket: 'uploads', Key: `u/${userId}/${crypto.randomUUID()}`,   // (1)
  ContentType: 'image/jpeg',
}), { expiresIn: 300 });                                          // (2)

The call asks the storage library for a URL that allows exactly one thing: a PUT of a JPEG image to one key in the uploads bucket.

(1) Your server chooses the key. It is built from the user's ID and a random identifier. The user's browser cannot change it, so a user cannot write over another user's files. This is the path-traversal defence from Chapter 8.5.1, applied to storage.

(2) The URL expires after 300 seconds, which is five minutes. It is kept short because the URL works for anyone who holds it. No password is asked for. Anyone who gets hold of the URL can use it until it expires.

The benefit is that your application never touches the file's bytes. A 5 GB upload uses none of your servers' network capacity and none of their memory, and it cannot run into their time limits. The resumable upload in Chapter 6.8.2 is built on exactly this.

There are two limits to know about.

A signed PUT cannot limit the size of the upload. A user could send a terabyte. There are two ways round this. You can use a signed POST policy, which is a different kind of signed upload that lets you state the smallest and largest size allowed. Or you can check the size after the upload has arrived, and delete the object if it is too big.

You must also fix the content type, as the code above does. Otherwise someone can upload a web page where you expected an image (Chapter 8.5.3).

6. Security ​

Block public access for the whole account. Every object-storage leak in the news was a bucket that somebody made public. The providers offer one switch that forbids public buckets across your whole account. That switch wins over the settings of any single bucket. So one person's mistake on one bucket cannot expose it. Turn the switch on, and make an exception only on purpose.

Control access with bucket policies, not with ACLs. A bucket policy is one document attached to a bucket that says who may do what. An ACL, or access control list, is an older mechanism that sets permissions on each object separately. ACLs are now switched off by default. A policy is easier to read and easier to check.

Encrypt the data. The store already encrypts every object before writing it to disk, using keys that the provider looks after. This is called server-side encryption. You can choose to use keys that you control (Chapter 8.6.1). That gives you two extra things. Every use of the key to decrypt an object is recorded. And you can cut off access to the data by withdrawing permission to use the key. There is also client-side encryption, where your application encrypts the file before uploading it. It is the only option under which the provider itself cannot read your data. The price is that features which need to read the object, such as server-side filtering, stop working.

Use a VPC endpoint. Then traffic between your servers and the bucket never crosses the internet. You can add a bucket policy that refuses any request that did not come through that endpoint (Chapter 5.10).

Turn on access logging. Every request to the bucket is recorded in a second bucket. For sensitive data, keep that second bucket in a separate account, so that an intruder cannot erase the record.

7. CDN topology ​

A CDN, or content delivery network, is a set of servers spread around the world that keep copies of your files close to your users. A stored copy is called a cache. The place the files really live, such as your bucket, is called the origin. Chapter 10.14.3 covers the rules of caching: how long a copy may be kept, and how to replace it. This section covers where the servers are and how they are arranged in layers.

Edge locations, also called points of presence, are hundreds of small sites close to users. Each one holds a cache.

Anycast routing sends each user to the nearest edge. The CDN announces the same IP address from every one of its edge locations. The internet's routing then delivers each user's request to the closest place that announces that address (Chapter 5.3.2). Nobody has to choose a server.

Regional edge caches sit between the edges and your origin. There are fewer of them. Each has far more storage than an edge, so it can keep files for longer.

These layers are the reason most requests are answered from a cache. Follow one file to see it.

A file is published from an origin in Sydney. A user in Los Angeles asks for it.

  1. The Los Angeles edge does not have the file. Finding nothing in a cache is called a miss.
  2. The edge asks its regional cache, which does not have it either.
  3. The regional cache fetches the file from Sydney. This one request is slow.
  4. The file is now kept at the regional cache and at the Los Angeles edge. The next user on the west coast gets it from the edge at once. Finding the file in a cache is called a hit.
  5. An edge has little storage, so after a while it drops the file to make room. The next request is then answered by the regional cache. It does not cross the Pacific again.

So the origin handles only a tiny share of the requests. Every user after the first gets a fast answer, wherever the file came from. The distance to the origin is paid once. It is not paid on every request.

An origin shield adds one more layer. You name one cache through which every other cache must fetch. A popular file is then requested from your origin once for the whole world, where before it was once for each region. This protects your origin when traffic suddenly jumps.

Being close is only one of four reasons a CDN is fast.

  1. The user's connection ends at the edge. Setting up an encrypted connection takes several messages back and forth, called the TLS handshake (Chapter 5.7). With a CDN, those messages travel only as far as the nearby edge.
  2. The long trip from the edge to the origin runs on the CDN's own backbone.
  3. The edge keeps connections to the origin open and ready, so no time is lost opening new ones.
  4. The edge speaks the newest and fastest versions of the web's protocols to the user (Chapter 5.6), even when your origin does not.

Two rules for running a CDN.

The cache key decides how often you get a hit. The cache key is what the CDN uses to decide whether two requests want the same file. Usually it is the URL. Suppose the URL contains something different for every user, such as ?session=8f3a. Then every user's request looks like a different file. The CDN stores a separate copy for each user and almost never gets a hit. The same thing happens if you tell the CDN to keep separate copies for each kind of browser.

Change the file's name when its content changes. Telling a CDN to throw away its copies is called invalidation. It is slow, CDNs limit how often you may do it, and many charge for it. So do not replace app.js in place. Publish app.3f9c2a.js, where the extra letters are a fingerprint worked out from the file's content. Such a file can be cached for a year. When the content changes, the name changes, so no old copy is ever served.

8. The Cloudflare story ​

Cloudflare is one of the largest CDN companies. Its history shows why CDNs became a normal part of nearly every website, and its outages show what you take on when you depend on one.

Cloudflare launched in 2010. It grew out of Project Honey Pot, a system its founders had built to track the senders of spam email. They had noticed something while running it. If you can see the attacks arriving at many websites at once, you can defend all of those sites better than any single site can defend itself.

The company gave away its basic service for free, on an anycast network. This looked generous, and it was also good business. Many free sites gave Cloudflare a reason to build many edge locations. A bigger network was a better network, and that attracted paying customers. The free sites also let Cloudflare see attack traffic across a large share of the web.

Anycast is also how Cloudflare absorbs attacks. A DDoS attack, short for distributed denial of service, floods a site with junk traffic from thousands of machines until it cannot answer real users. With anycast, each attacking machine reaches the Cloudflare location nearest to itself. So the flood is split across the whole network, and no single place receives all of it. The network's capacity is shared by every customer. A small site can therefore survive an attack far larger than it could ever have paid to withstand on its own.

Cloudflare Workers run your code at the edge. A Worker does not start a container for your code. It uses a V8 isolate, which is a very light sandbox inside the JavaScript engine (Chapter 3.6.9). An isolate starts in under a millisecond. A container takes hundreds of milliseconds.

The outages teach the most, because each one shows a general lesson.

  • 2019. Engineers sent a new firewall rule to every location at once. The rule contained a regular expression, which is a pattern for matching text. This particular pattern took an enormous amount of work to check against certain inputs, a fault called catastrophic backtracking (Chapter 3.6.10). It used up the CPU on every server, and the network went down. Lesson: a configuration change sent everywhere at once is as dangerous as a new version of the code. It should be rolled out in stages, a few locations first, in the same way.

  • 2020. A change to routing on the backbone caused a large loss of traffic. Lesson: a network is run by software, so it fails in the ways software fails.

  • 2022. A change made during a network upgrade took out the data centres that carried a large share of the traffic. Lesson: when one central system controls everything, a mistake in it can take down everything.

  • 18 November 2025 — the longest of them, nearly six hours, from 11:20 to 17:06 UTC. The chain is worth following step by step, because each link is ordinary:

    1. Engineers changed database permissions on an internal ClickHouse cluster, a routine security improvement.
    2. A query that builds a configuration file for the bot-detection system did not say which database to read. After the permission change it saw a second database, so it returned every row twice.
    3. The file doubled in size, from about 60 features to more than the proxy's hard limit of 200.
    4. The file was copied to every server in the network within minutes, as designed.
    5. The proxy code checked the limit, and on failure it crashed instead of keeping the old file. Every request through those servers returned an error.

    Lesson: a file your own systems generate is still input, and must be checked like input. Cloudflare's stated fixes were to validate its own generated files the way it validates customer input, and to add global kill switches for features.

When you put a CDN in front of your site, your site is up only when the CDN is up. That is usually a good trade, because a CDN is down less often than your own servers would be. But make the decision knowingly, and have a plan for the day the CDN fails.

9. Choosing a storage type ​

NeedUse
A disk for one machineBlock storage
A shared filesystem for several machinesFile storage
Files served to users, backups, data lakeObject storage
Scratch space, fastest possibleLocal instance storage (lost on stop)
Static assets and media to usersObject storage behind a CDN

Block storage, file storage and local instance storage were introduced in Chapter 13.1.

Put static content in object storage, put a CDN in front of it, and never serve it from your application. Static content means files that are the same for every user, such as images, stylesheets and scripts. Serving them this way is cheaper, faster and more reliable. It also takes all of that traffic away from the application servers that you have to run yourself.

What the interviewer will push on ​

"How is object storage different from a filesystem?" Flat key-value: no directories, no rename (copy plus delete), no append or partial write, and listing is a paginated prefix scan. The consequence that matters is that "rename a folder" is a job over every object, and that you should derive keys or index them rather than listing to find things.

"Eleven nines of durability — what does that protect against?" Hardware and facility loss, through erasure coding across zones. Not deletion, not overwriting, not ransomware, not a bad script. Those need versioning, object lock (which even an administrator cannot bypass) and cross-account replication.

"How would you handle large user uploads?" Pre-signed URL direct to storage, with your server choosing the key so the client cannot write outside its space, a short expiry, multipart above ~100 MB, and a storage event to trigger processing. Then the two constraints: a signed PUT cannot limit size, and content type must be enforced.

"Why is content from a distant origin still fast on a CDN?" Only the first request pays the distance. After that it is cached at the local edge, and when it ages out of the edge it is served by a regional cache rather than crossing the ocean again. The hierarchy is the answer, and origin shield reduces origin fetches to one globally.

"What silently costs money in object storage?" Incomplete multipart uploads (charged, invisible in a listing), old versions with no expiry rule, small-object request charges, and archive retrieval fees on data a lifecycle rule moved down. Naming incomplete multiparts is the tell — almost nobody mentions it and almost every large bucket has them.

"What do you lose by depending on a CDN?" Their availability becomes yours, and a global configuration change on their side is a global change to your service. It is usually a good trade, and it needs a conscious decision, an origin that can serve directly, and a plan for the day it fails.

One thing to volunteer: point out that a CDN configuration change is deployed globally in seconds, which makes it more dangerous than a code deploy — Cloudflare's 2019 regular-expression outage is the clearest case. Staged rollout for configuration, not just for code, is the lesson worth carrying into your own edge rules.

Recall

  • Object storage is a flat key-value store: no directories, no rename (copy plus delete), no append, and listing is a paginated prefix scan. Reads are strongly consistent; listings can lag, so pass keys forward rather than re-listing.
  • Durability ≠ availability, and neither protects against deletion or ransomware. Versioning, object lock (an administrator cannot delete), and cross-account replication do — and old versions are charged, so expire them.
  • Storage classes trade cheap storage for retrieval fees and retrieval time — archive restores take hours. Move tiers on measured access, not age. Always add a lifecycle rule expiring incomplete multipart uploads — charged and invisible.
  • Request rate scales per key prefix, so sequential timestamp prefixes create a hot partition. Multipart above 5 GB (required) and ~100 MB (worthwhile); byte-range requests power seeking and columnar reads.
  • Pre-signed URLs keep bytes out of your application. Your server chooses the key; expiry is short because the URL is a bearer credential; a signed PUT cannot limit size — use a POST policy or check afterwards.
  • Block public access at the account level, policies over ACLs, encryption with your own keys for an audit trail, VPC endpoints, and access logs in a separate account.
  • CDN is a hierarchy: anycast to hundreds of edges, then regional edge caches, then optionally an origin shield so a popular object is fetched from origin once globally. Distance to origin costs one request, not every request. Cache keys decide hit ratio; prefer versioned URLs over invalidation.
  • Cloudflare's model was a free tier on an anycast network, absorbing attacks with shared capacity. Its outages taught that a global configuration change is as dangerous as a code deploy and needs staged rollout.

Self-test: Why is renaming a prefix an expensive job? · What does eleven nines not protect you from? · Which lifecycle rule is almost always missing? · Why does a sequential key prefix hurt throughput? · Who chooses the key in a pre-signed upload, and why? · Why is only the first request slow for distant content?

Next: the last four pages applied to every provider. 13.5 goes into one provider in depth. It covers how Azure organises resources, how it controls access through identity, the Microsoft Graph API, and why Azure gives you two keys for everything.

Combine chapters into one PDF

Pick the chapters you want. They print in the order you pick them.

Volume I — Technology
Part 0 — Retention & Notation
Part 1 — Foundations of Computation
Part 2 — Operating Systems
2.1 The Kernel
2.2 Processes
2.3 Threads & Scheduling
2.4 Concurrency Under the Hood
2.5 Memory Management
2.6 File Systems
2.7 Input/Output
2.8 Linux for Engineers
2.9 Windows & macOS in Practice
Part 3 — Languages, Compilers & Runtimes
3.6 JavaScript & V8
3.7 TypeScript
3.8 Node.js Internals
3.13 Python & CPython
3.14 FastAPI & Production Python
Part 4 — Data Structures & Algorithms
4.0 Classic Problems — Before NeetCode
4.4 Arrays & Hashing — Problems
4.5 Two Pointers
4.6 Sliding Window
4.8 Stack — Problems
4.9 Linked List — Problems
4.11 Binary Search — Problems
4.13 Trees
4.14 Tree — Problems
4.15 Trie — Problems
4.17 Heap — Problems
4.18 Backtracking — Problems
4.19 Graphs
4.20 Graph — Problems
4.21 Advanced Graph — Problems
4.23 1-D DP — Problems
4.24 2-D DP — Problems
4.26 Greedy — Problems
4.27 Interval — Problems
4.28 Math & Geometry — Problems
4.30 Bit Manipulation — Problems
Part 5 — Networking & the Web
5.3 IP
5.4 Transport
5.6 HTTP
Part 6 — Frontend Engineering
6.1 Browser Internals
6.2 HTML & CSS Mastery
6.3 JavaScript in the Browser
6.4 React, from First Component to Full Shop
6.5 Frameworks & Rendering
6.8 UI Engineering & Patterns
Part 7 — Databases & Storage
7.2 SQL Mastery
7.3 Storage Engine Internals
7.4 Transactions
7.5 NoSQL Taxonomy
7.8 Analytics & Big Data
Part 8 — Security, Identity & Cryptography
8.2 Cryptography
8.3 Protocols of Trust
8.4 Identity: AuthN & AuthZ
8.5 Application Security
8.6 Infrastructure Security
Part 9 — Software Design (LLD)
9.2 OOP Foundations
9.3 Design Principles
9.4 Design Patterns
9.5 Concurrency
9.6 API Design
9.7 LLD Interview Machines
9.9 Node/Express Production Playbook
Part 10 — Distributed Systems & HLD
10.7 Consistency & Consensus
10.8 Messaging & Microservices
10.14 Caching
Building blocks from the design seat
Part 11 — System Design Case Studies
Part 12 — AI & ML Engineering
12.1 What AI Engineering Is
12.2 The Math You Need
12.3 Classical Machine Learning
12.4 Data for ML
12.5 Deep Learning
12.6 Embeddings & Vector Search
12.7 Transformers & LLMs
12.8 Building with LLMs
12.9 Retrieval-Augmented Generation
12.10 Agents
12.11 Adapting Models
12.12 Production AI
12.13 Multimodal AI
12.14 AI Security & Governance
12.15 Case Studies & Capstone
Part 13 — Cloud, DevOps & Infrastructure
13.11 Git, from First Commit to Team Workflow
Part 14 — Containers: Docker & Kubernetes
14.1 Foundations
14.2 Docker
14.3 Kubernetes
14.4 Kubernetes on Azure
Part 15 — The Craft & Career
Nothing picked yet