S3-like Object Storage
Ch. 25 Case Studies System designThe problem
There are three ways to store bytes, and they differ in one important thing: how the storage sees the file. Block storage carves a disk into raw sectors and hands them to one owner, who builds the file system on top. File storage keeps a tree of directories and lets a process open a handle and seek within a file. Object storage throws both of those away. It keeps a flat set of keys, and a key maps to a blob of bytes plus a small set of metadata. There is no tree, no seek, no partial overwrite — you put an object, you get an object back, and if you want a different object you put a new one.
That flatness and that immutability are not arbitrary design choices; they are the load-bearing facts of the whole system. Because the namespace is flat, the key space shards cleanly and scales out with almost no coordination. Because an object is immutable, a read is a simple lookup and a write is an atomic publish — no reader ever sees a half-written file. Multipart uploads, versioning, lifecycle tiering, and the durability mechanism all fall out of those two facts. We will build the data model, the read path, the multipart write path, the sharding that makes the key space scale, the durability that makes it trustworthy, and the lifecycle that moves cold data to cheaper tiers — and close the loop with one object that is uploaded in parts, published atomically, read back, versioned, and eventually tiered down.
Requirements
Functional — what it must do
- Store: a client uploads an object under a key in a bucket, and the system keeps it durably with its metadata, including objects far larger than memory or a single request.
- Retrieve: a client requests an object by its key and gets back its full content and metadata, and can request a range of bytes instead of the whole object.
- Manage: the system supports listing a prefix of keys, versioning an object so an older one survives a newer put, and moving or deleting objects as they age.
Non-functional — how well it must do it
- Durability: an object, once acknowledged, is effectively not lost — the design tolerates the loss of whole disks and whole availability zones without losing data.
- Atomicity: a reader never sees a partially uploaded object; an object is either fully present or not present at all.
- Scale: the key space holds on the order of a trillion objects and grows without a redesign; a single hot prefix does not pin all of its traffic to one machine.
- Availability: a read succeeds with high probability even while individual disks or nodes are down, by reconstructing the object from its surviving pieces.
Scale — how much it must take
- On the order of a trillion objects across many buckets, objects from a few kilobytes to tens of terabytes, with reads and writes at tens of millions of operations per second at peak.
Assumptions — the numbers this design is sized for
A rate limit means nothing without a scale. These are the figures every later part relies on: how much traffic arrives, how much work the limiter has to do per second, and how much latency and memory it may spend doing it.
Takeaways
- Object storage is a flat key space over immutable blobs: there is no directory tree (so the key space shards cleanly by key hash) and no in-place mutation (so a read is a simple lookup and a write is an atomic publish) — those two facts are the design, and multipart, versioning, and durability all fall out of them.
- An object is a key, a small metadata record, and the content; the key is a string (slashes are cosmetic, not a path), the metadata carries the version, an ETag, and the location of the bytes, and the content is immutable and addressed by location.
- A large upload is multipart: the parts are stored but the key is not resolvable until the completion call assembles them and publishes the key atomically, so no reader ever sees a partial object — the write is 'make the key point to this content', an all-or-nothing step.
- A read is a lookup by key plus a reconstruction of the content from the available pieces, and it supports ranges and ETag-conditional reads; because the content is immutable, a read of a given version returns exactly the same bytes every time, with no torn reads.
- Versioning makes an overwrite a new object: a put adds a version and the old one remains addressable by its id, a delete of the key is a reversible delete-marker, and an explicit delete of a version id is the only irreversible removal.
- Durability is carried by erasure coding, not three copies: the content is split into data and parity pieces spread across disks and zones, a read reconstructs the object from a quorum of surviving pieces, and the loss of a disk or a zone costs pieces the code can spare — not the data.
Objects, not files
The three storage families differ in how the storage sees the data. Block storage is raw sectors, file storage is a seekable tree, and object storage is a flat map from keys to immutable blobs. The last two properties — flat and immutable — are the design.
- 1Three ways to store bytes
Block storage carves a disk into sectors and hands them to one owner, who builds the file system on top — fast, but one owner, one machine. File storage keeps a tree of directories and lets a process open a handle and seek anywhere in a file, changing it in place — flexible, but the tree is a coordination problem at scale. Object storage throws both away: a flat set of keys, each mapping to a blob of bytes and a little metadata. You put a whole object, you get a whole object back, and you never seek or partially rewrite one.
- 2Flat and immutable — the two facts
Two properties do most of the work. The namespace is flat: there is no directory tree, so the key space is one big set that partitions cleanly by key hash, and scaling out is a matter of handing different key ranges to different machines with no tree to rebalance. And the content is immutable: an object is never changed in place, so a reader never sees a half-written file, and a write is an atomic publish of a whole object. Every later piece of the design — multipart, versioning, durability — is a consequence of those two facts.
The data model: key, metadata, content
An object is three things: a key, a small set of metadata, and the content. The key is the address, the metadata carries the version and where the bytes live, and the content is the immutable payload. 'Folders' are just delimiters in the key — there is no tree.
- 1A key, not a path
The address of an object is a key: a bucket name plus a string. A string that happens to contain slashes looks like a path to a human, but to the system it is just a key — there is no hierarchy to walk, no directory to lock, no path to resolve. That is the flatness in practice. It is also why 'moving' an object is a new put, not a rename, and why listing a 'folder' is a prefix scan over the flat key space, not a tree traversal.
- 2Metadata carries the version and the location
The metadata of an object is small and is the part that is looked up. It records the object's content type, its size, an ETag that identifies this exact content, a version number that distinguishes it from other puts of the same key, and the location — which shard holds the bytes. The content itself is addressed by that location, not by the key. The key maps to the metadata; the metadata maps to the content. Separating the two is what makes a read a two-step lookup instead of one giant fetch.
The read path
A read is a lookup by key: the service authorises the request, looks up the metadata to find the version and the location, and fetches the bytes from the blob store. Ranges let a client pull a slice of a large object instead of the whole thing.
- 1Key in, content out
A client sends a key. The service authorises the request and looks up the key in the metadata store, which returns the version and the location of the bytes. The service then fetches the content from that location in the blob store and returns it, with the metadata, to the client. Because the object is immutable, there is no locking and no risk of a half-read — the bytes the client gets are exactly the bytes that were published. A read is a lookup plus a fetch, and both are read-only.
- 2Ranges, not whole objects
Objects can be tens of terabytes, so a read does not have to return the whole one. A client can request a range — bytes 100 to 199 — and the service returns exactly that slice. This is what lets a streaming client pull a video a chunk at a time, and what lets a resume-after-failure download pick up where it left off. The range is an offset into the immutable content, so it is stable: the slice a client reads at one moment is the same slice it would read at any later moment, as long as the version is the same.
- 3Conditional reads with the ETag
The ETag identifies a specific version of the content. A client can send a conditional read — 'give me the object only if its ETag matches what I last saw' — and the service returns the content only if the version has not changed, or a 'not modified' response if it has. This is how a client avoids re-downloading an object it already has, and it is a direct consequence of immutability: because a put creates a new version with a new ETag, the ETag is a stable fingerprint of the content.
The write path: multipart, then publish
A small object is one put. A large one cannot be one request, so it is uploaded as parts, and the parts are assembled into the object only at completion. Until that moment the key is not readable, so no reader ever sees a partial object.
- 1One put for small, parts for large
An object up to a few tens of megabytes is a single put: the client sends the content, the service writes it and returns. An object of gigabytes or terabytes cannot be one request, so the client splits it into parts, uploads the parts in parallel, and sends a completion call that names the parts in order. The service assembles the parts into the object and publishes it. Splitting into parts is what makes a large upload resumable and parallel, and it is a consequence of the object being a flat, addressable blob rather than a file with a handle.
- 2Parts are stored, but not visible
As the client uploads each part, the service stores it, but the key is not yet resolvable. The parts sit in a staging area, each identified by the upload id and the part number, and none of them is reachable through the key. That is the crucial property: an in-progress multipart upload is invisible to readers. A client reading the key during the upload gets a 'not found', never a partial object. The object only comes into existence when the completion call is processed and the parts are assembled.
- 3Completion is the atomic publish
The completion call names the parts in order. The service verifies that the expected parts are present, assembles them into the object, writes the metadata, and then — in a single step — makes the key resolve to the new object. Before that step, the key is not readable; after it, the key returns the full object atomically. There is no window in which a reader sees part of the object. That atomic publish is what the flat, immutable model buys us: the write is 'make the key point to this content', and 'point to' is a single, all-or-nothing operation.
Versioning: an overwrite is a new object
Because an object is immutable, putting a key again does not change the old object — it adds a version. The new version is the current one; the old one remains, addressable by its version id, until it is explicitly deleted. This is 'undo' for free, and it is why a read can be exactly-once in the strong sense.
- 1Put again, and the old one survives
When a client puts a key, the service does not overwrite the existing object. It creates a new version with a new version id and a new ETag, and the key now resolves to the new version. The old version is still there, addressable by its version id, and a read of the key returns the latest version. This is the immutability in service of the user: a mistaken put is recoverable, because the previous version has not been destroyed. Overwriting, in the file-storage sense — changing bytes in place — simply does not happen.
- 2Delete-marker and explicit delete
Deleting a key is also a version operation. A delete, when versioning is on, adds a delete-marker version rather than destroying the current version, so the key appears gone to a normal read but the underlying object still exists and can be restored. An explicit delete of a specific version id is what actually removes an object. This keeps the 'delete' and 'undo' semantics clean: the default delete is reversible, and the irreversible one requires the version id.
- 3Why immutability makes a read exactly-once
In file storage, a read can return bytes that are in the middle of being written, because the file is being changed in place. In object storage that cannot happen, because the content is never changed — a new version is a new object. So a read of a specific version always returns exactly the bytes of that version, every time, forever, until that version is explicitly deleted. The 'exactly-once' of a read is not a concurrency trick; it is a consequence of the object not being mutable at all.
Sharding a trillion keys
The key space is flat, so it partitions by key hash into ranges, and each range is owned by a shard. Adding capacity is adding shards and rebalancing a range. Listing a prefix is a scan over the key space with a token, so it too scales out.
- 1The key space partitions, not the tree
Because there is no directory tree, the key space is one big flat set, and it partitions cleanly: the service hashes the key and assigns the key range to a shard. Each shard owns a contiguous range of hashes and serves the objects in that range. Scaling out is a matter of adding shards and rebalancing a range of keys to them — there is no tree to rebalance, no directory to lock. A trillion keys is a trillion hash values spread across many shards, and the system scales by adding shards, not by making one shard bigger.
- 2Listing is a prefix scan with a token
Listing the objects under a prefix — the 'show me everything in this folder' request — is a scan over the flat key space, not a tree traversal. The client sends a prefix and a token, and the service returns a page of keys and a new token to continue from. The token marks how far the scan has progressed, so a listing of a million keys is a sequence of bounded pages, each served by whichever shard owns the relevant key range. A hot prefix does not pin all of its traffic to one machine, because the keys are spread by hash across the shards.
- 3The flat namespace is the scalability
This is where the flatness pays for itself. A file system scales by making the tree shallower or the inodes bigger — coordination is the cost. An object store scales by adding shards to a flat key space — coordination is the benefit. The same two facts that made a read a simple lookup and a write an atomic publish are what make a trillion keys a tractable problem. Flatness is not a limitation of object storage; it is the reason it can be a trillion objects at all.
Durability: erasure coding, not copies
Replicating every object three times is simple but wasteful. Erasure coding splits the content into data and parity pieces spread across disks and zones, so the object can be reconstructed from a subset of the pieces — the loss of a disk or a zone does not lose the data.
- 1Coding beats copying
The naive durability mechanism is replication: keep three full copies of every object and lose at most two. That works, but it costs three times the storage. Erasure coding is cheaper and just as safe. The object is split into a number of data pieces plus a number of parity pieces, and the pieces are spread across different disks and, where possible, different zones. As long as enough of the pieces survive, the original object can be reconstructed exactly. Losing a disk, or even a whole zone, costs a few pieces — not the data.
- 2The object is the pieces
When an object is written, the service encodes it into its data and parity pieces and writes the pieces to different disks and zones. The object, as far as the system is concerned, is the set of pieces plus the parameters of the code — not a single contiguous blob on one disk. A read reconstructs the content from whatever pieces are available, so a read succeeds as long as the code's quorum of pieces is present. That is what '11 nines of durability' means in practice: the loss of any single disk, or any single zone, removes pieces the code can spare, and the object is still fully recoverable.
- 3Reconstruction is the read
A read, in this model, is a reconstruction. The service finds which pieces are available, fetches the quorum it needs, and decodes them back into the object's content. If a disk is down, the read simply uses the surviving pieces and reconstructs the missing one from the parity. The reader does not know or care which disk failed — the content comes back whole. Durability, in this design, is not 'we hope the copies are there'; it is 'we can always reconstruct it from the pieces that are'.
End to end
One object's life: uploaded in parts and published atomically, read back by key, overwritten into a new version with the old one surviving, and eventually tiered down to cheaper storage as it ages — with durability carried by the erasure-coded pieces at every step.
- 1The whole system
Every piece in one frame. A client uploads an object, either as a single put or as parts that are completed into an atomic publish. The service stores the metadata and the erasure-coded content across shards and zones. A read looks up the metadata and reconstructs the content from the available pieces. Versioning keeps each put addressable. And the lifecycle engine moves cold objects to cheaper tiers and deletes the ones that are past their retention. One object, many lives, all recoverable.
- 2Uploaded in parts, published atomically
A client uploads a large object. The service opens a multipart upload and returns an id; the client uploads the parts in parallel, and each part is stored but the key is not yet resolvable. The client sends the completion call naming the parts in order, and the service assembles them, writes the metadata, and publishes the key in one atomic step. From that moment the object is readable, and from no moment before it was. No reader ever saw a partial object.
- 3Read back, and overwritten into a new version
A client reads the object by key: the service looks up the metadata, finds the version and the location, and reconstructs the content from the available pieces, returning it whole. Later, a client puts the key again. The service does not overwrite — it creates a new version, and the key now resolves to the new one, while the old version remains addressable by its id. The read is exactly-once in the strong sense, because the content is immutable.
- 4Tiered down as it ages
Days or weeks later, the object is cold. The lifecycle engine, which has been evaluating age and access patterns, moves it to a cheaper tier — the content is re-encoded for the lower-cost storage, the metadata is updated to point there, and a read is transparently served from the new tier. The object is the same object, the same key, the same versions; only the cost of holding it has changed. The two load-bearing facts carried it the whole way: flatness kept the key space shardable, and immutability kept every read and version exactly what it was.
In the wild
Object storage is the substrate for most large-scale data workloads. The boxes below are anchored to the classes of well-known systems that run each piece — an illustrative mapping, not a claim about any one product's internals.
- 1The pattern, piece by piece
Each box is a standard building block of an object store. Anchoring them to the classes of production systems that run that piece turns the abstract design into the shape behind the bucket that holds a trillion objects and serves them at millions of operations a second.
- 2Why the same pieces keep winning
Independent object stores converge on the same pieces because each one removes a real failure: the flat key space removes the tree-rebalancing cost, the atomic publish removes the torn-write failure, the versioning removes the mistaken-overwrite failure, the erasure coding removes the lost-data failure, and the lifecycle removes the paying-full-price-for-cold-data failure. That convergence across independent systems is the evidence the design is load-bearing.