The Problem#
Design an object store like Amazon S3, Google Cloud Storage or Azure Blob Storage. Customers create buckets and store objects in them: a photo, a log file, a database backup, a 4 TB video master. Each object is a blob of bytes plus a little metadata, addressed by a key such as photos/2026/03/beach.jpg. Customers can put, get, delete and list objects over HTTP, from anywhere, at any scale, and they expect never to lose a single byte.
The interface is tiny. Behind it sits one of the hardest engineering problems in industry:
- Durability at absurd scale. A large region stores trillions of objects on hundreds of thousands of disks. Several disks fail every day, whole racks lose power, and every so often an entire data centre goes dark. The store must lose essentially nothing: "eleven nines" of durability means that if you store 10 million objects, you would expect to lose one about every 10,000 years.
- Two very different kinds of data. Metadata (which objects exist, where their bytes are) is small, hot and needs strong consistency. Data (the bytes) is huge, mostly cold, and needs cheap, durable, high-throughput storage. They need different designs.
- Cost. At exabytes, every percent of storage overhead costs a fortune. Three full copies of everything is affordable for a small system, ruinous for a large one. Erasure coding, which gives better durability with half the overhead, is the core trick.
- Correctness under concurrency. After a successful write, every reader must see it. Two clients overwriting the same key at once must produce one clear winner. A deleted object must disappear from listings. All while the system is constantly repairing, rebalancing and upgrading itself.
Analogy. Think of a gigantic warehouse company with many buildings. The goods (the bytes) sit on shelves in sealed boxes; the company does not care what is in them. A central catalogue (the metadata) records "item beach.jpg = boxes 7718, 7719 in buildings A, B and C". To protect against fire, the company does not just keep three copies of every box. It cuts each item into six pieces, computes three extra "recovery pieces" with clever arithmetic, and spreads all nine across different buildings; any six of the nine are enough to rebuild the item. When a shelf collapses, crews rebuild the lost pieces from the survivors before more shelves fail. Customers never talk to the shelves directly; they ask the front desk, which checks the catalogue and fetches the pieces. Object storage is exactly this: front ends, a metadata catalogue, data nodes holding pieces, erasure coding as the recovery pieces, and a repair process racing against failure.
S3 launched in 2006 and has become the default storage layer of the cloud. Data lakes, backups, media, machine-learning datasets and many databases now sit on top of it. This case study designs a regional object store of that kind from scratch. It is the layer underneath the File Sync, Video Streaming and Instagram case studies, which treat blob storage as a given.
Clarifying Questions#
| Question | Assumed answer | Why it matters |
|---|---|---|
| Which operations? | Create and delete bucket; PUT, GET (including byte ranges), HEAD, DELETE and LIST of objects; multipart upload; object versioning | Defines the API and what metadata must support (LIST needs ordered keys) |
| Object sizes? | From 0 bytes to 5 TB; most objects by count are small (under 1 MB), most bytes are in large objects | Small and large objects need different storage layouts |
| Scale of one region? | About 1 EB stored, 10 trillion objects, several million requests per second at peak | Drives metadata sharding and disk counts |
| Durability target? | 99.999999999% (eleven nines) per object per year | Drives redundancy scheme, placement and repair speed |
| Availability target? | 99.99% for reads and writes | Requires surviving a whole availability zone (data centre) failure |
| Consistency? | Strong read-after-write for PUT, overwrite, DELETE and LIST | Metadata must be linearisable per key |
| Is the data mutable? | Objects are immutable; an overwrite replaces the whole object | No partial in-place updates simplifies everything |
| Multiple regions? | One region in the core design; cross-region replication as an add-on | Keeps the core design within one region's network |
| Storage classes? | A standard class, plus a cheaper infrequent-access or archive class as an extension | Lifecycle and tiering affect placement and GC |
| Security? | Per-request authentication, bucket policies, encryption at rest | Affects front end and data path but not storage layout |
Requirements#
Functional Requirements#
- Buckets: create, delete and list buckets; bucket names are globally unique.
- Objects:
PUTan object (up to 5 GB in one request),GETit (whole or a byte range),HEADit (metadata only),DELETEit. - List: list keys in a bucket in lexicographic order, with a prefix filter, a delimiter (to simulate folders) and pagination.
- Multipart upload: upload large objects (up to 5 TB) in parts, in parallel and resumably, then complete them into one object.
- Versioning: optionally keep every version of a key; a delete adds a delete marker rather than destroying data.
- Conditional requests: "write only if the key does not exist" and "write only if the current version is X", so clients can build safe read-modify-write cycles.
Out of scope for the core: the full identity and access management system, event notifications, query-in-place features, static website hosting. We note where each plugs in.
Non-Functional Requirements#
- Durability: eleven nines per object per year. Acknowledged writes must survive the loss of any disk, server, rack, or one entire availability zone.
- Availability: 99.99% for reads and writes in a region, even during the loss of one availability zone.
- Strong consistency: after a successful PUT or DELETE returns, every subsequent GET, HEAD and LIST reflects it.
- Scalability: practically unlimited objects per bucket; throughput that grows with the number of key prefixes used.
- Performance: first-byte latency in tens of milliseconds for standard storage; throughput limited by the client's network for large objects.
- Cost efficiency: raw storage overhead well below the 3 times of triple replication for large data, roughly 1.5 to 2 times depending on how many failures we must survive.
- Integrity: every byte checksummed end to end; silent corruption detected and repaired.
Note that durability and availability are different promises. Availability means "I can read or write right now". Durability means "the data still exists". A system can be unavailable for an hour without losing anything; it can also be perfectly available while silently losing objects. The design must achieve both, and it achieves them by different means: availability by redundant front ends and quorum-style writes across zones, durability by redundancy plus fast repair.
Capacity Estimation#
We size one large region. The point is to find what is big: disks, failure rates, repair traffic, metadata and request rates. Method: Back-of-the-Envelope Estimation; reference numbers: Numbers Every Engineer Should Know.
Objects and bytes. 1 EB of logical data in 10 trillion objects, an average of 100 KB per object. The average hides a skewed distribution that matters for the design: most objects by count are small (thumbnails, JSON, logs, under 100 KB), while most bytes live in large objects (backups, media, data-lake files of hundreds of megabytes or more). Assume 80 percent of objects are under 100 KB but hold only about 2 percent of the bytes.
Raw disk. Large data is erasure coded with a scheme that survives the loss of an entire availability zone, which costs about 1.8 times the logical size (we derive this in the erasure coding deep dive). Small objects may be replicated three times, but they are only 2 percent of bytes, so they barely move the total. Raw data: about 1 EB x 1.8 = 1.8 EB. Disks are not run full: we keep 25 percent free for growth, repairs and rebalancing, so we need about 2.4 EB of disk.
Drives and servers. With 20 TB hard drives, 2.4 EB / 20 TB = about 120,000 drives. Packed 60 per storage server (dense JBOD chassis), that is about 2,000 storage servers, spread across three availability zones.
Failures are constant. Large fleets see an annualised failure rate (AFR) of about 1 to 2 percent per hard drive; take 1.5 percent. Then 120,000 x 0.015 = 1,800 drive failures a year, about 5 a day. Servers, power supplies, network switches and whole racks fail too, less often but taking out dozens of drives at once. The system is never "healthy"; it is always repairing.
Repair traffic. Each failed drive held about 15 TB (75 percent full). Rebuilding a lost erasure-coded fragment requires reading k surviving fragments, so with k = 12 the repair reads twelve times what it writes. 5 drives a day x 15 TB x 12 = 900 TB of repair reads per day, about 85 Gbps sustained, plus 75 TB of writes. That is affordable inside a region, but it is a large, permanent background load, and it is why "repair-efficient" codes (local reconstruction codes) exist.
Request rates. Peak 5 million requests per second: 3.5 million GETs, 1 million PUTs, 0.5 million HEAD, LIST and DELETE. Every request touches metadata: a GET needs a lookup, a PUT needs a metadata write. So the metadata tier must sustain about 1 million writes per second and 4 million reads per second at peak.
Metadata size. Each object's metadata record holds the bucket and key (keys average around 100 bytes and may be up to 1 KB), version id, size, checksums, timestamps, user metadata, storage class and the list of data locations: roughly 500 bytes. 10 trillion x 500 bytes = 5 PB of metadata, about 15 PB with three replicas. This is not a database you buy and run on one machine; it is a distributed index sharded into thousands of partitions on SSD. At 2 TB per partition, that is about 2,500 partitions, each replicated three ways.
Bandwidth. GETs: 3.5 million x 100 KB average = 350 GB/s, about 2.8 Tbps out of the region's storage tier at peak. PUTs: 1 million x 100 KB = 100 GB/s in, about 0.8 Tbps, which erasure coding inflates to about 1.4 Tbps of internal writes across zones. Cross-zone network capacity is therefore a first-class resource.
Disk IOPS: the hidden limit. A hard drive does about 100 to 200 random I/Os per second regardless of its capacity. 120,000 drives x 120 IOPS = about 14 million random IOPS for the whole region. Serving 3.5 million GETs per second, plus PUTs, repair and scrubbing, fits only if each GET costs about one disk I/O. A design that spends three I/Os per GET on file-system metadata (look up directory, read inode, read data) would run out. That is why data nodes keep their object index in memory or on SSD and read data with a single seek, and why hot objects must be spread over many drives. As drives grow (20, 24, 30 TB), IOPS per terabyte falls, which makes this limit tighter every year.
| Quantity | Estimate | What it drives |
|---|---|---|
| Logical data / objects | 1 EB / 10 trillion | Everything below |
| Raw disk (EC about 1.8x, 75% full) | about 2.4 EB | Hardware cost |
| Drives / storage servers | about 120,000 / 2,000 | Placement, failure domains |
| Drive failures | about 5 per day | Continuous repair |
| Repair reads with k = 12 | about 900 TB per day | Repair-efficient codes, throttling |
| Peak requests | 5 M/s (3.5 M GET, 1 M PUT) | Front-end fleet, metadata tier |
| Metadata | about 5 PB, 2,500 partitions | Sharded, range-partitioned index |
| Peak egress / ingress | about 2.8 / 0.8 Tbps | Network fabric, cross-AZ links |
| HDD random IOPS budget | about 14 M/s | One I/O per GET, in-memory indexes, heat spreading |
Core Entities#
- Account: a customer, the owner of buckets and the unit of billing and quotas.
- Bucket: a named container of objects with settings: region, versioning on or off, access policy, encryption default, lifecycle rules. Bucket names are globally unique so they can appear in DNS names.
- Object: the user-visible thing, identified by
(bucket, key). Immutable bytes plus system metadata (size, checksums, content type, timestamps) and user metadata (small key-value pairs). - Object version: one immutable incarnation of a key. With versioning off, a key has one current version and an overwrite replaces it; with versioning on, all versions are kept and the newest is current. A delete marker is a special version that says "the key is deleted as of now".
- Chunk (extent): a contiguous piece of an object's data, the unit the data tier stores, a few megabytes for large objects. Small objects are packed together into shared chunks.
- Stripe: a group of k data chunks plus m parity chunks computed by erasure coding, placed on k + m different disks in different failure domains.
- Fragment: one chunk of a stripe as stored on one particular disk.
- Data node, disk: a storage server and its drives; each has a location in the failure-domain tree (zone, room, rack, server).
- Placement group (or volume): a set of disks chosen together to hold many stripes. Assigning data to groups rather than choosing disks per chunk keeps placement metadata small and controls how failures overlap.
- Multipart upload and part: an in-progress large upload and its independently uploaded pieces.
In an interview, start with Bucket, Object and the split between object metadata and object data, and add stripes, fragments and placement groups as the deep dives need them.
API Design#
The public API is HTTP and REST-like, as in S3. Every request is authenticated by a signature over the request (for S3, Signature Version 4: an HMAC chain over a canonical form of the method, path, query, selected headers and a hash of the body, keyed by a key derived from the secret access key, date, region and service). The same signature scheme, placed in query parameters, gives presigned URLs that let a third party perform one operation until an expiry time.
# Buckets
PUT /{bucket} create bucket
DELETE /{bucket} delete (must be empty)
GET / list my buckets
# Objects
PUT /{bucket}/{key} body: bytes -> 200, ETag, x-version-id
headers: Content-Length, x-checksum-sha256, If-None-Match: *, If-Match: "etag"
GET /{bucket}/{key}[?versionId=v] Range: bytes=0-1048575 -> bytes
HEAD /{bucket}/{key} -> metadata only
DELETE /{bucket}/{key}[?versionId=v] -> 204
# Listing
GET /{bucket}?list-type=2&prefix=photos/2026/&delimiter=/&max-keys=1000
&continuation-token=... -> keys, common prefixes, next token
# Multipart upload
POST /{bucket}/{key}?uploads -> UploadId
PUT /{bucket}/{key}?partNumber=7&uploadId=U body: part bytes -> ETag
GET /{bucket}/{key}?uploadId=U list uploaded parts
POST /{bucket}/{key}?uploadId=U body: [ {partNumber, ETag}, ... ] -> final ETag
DELETE /{bucket}/{key}?uploadId=U abort, free the partsSome details that shape the internals:
- ETag. A fingerprint of the object version. For single-part uploads without customer-managed encryption, it has traditionally been the MD5 of the content. For multipart objects, it is derived from the part checksums plus a part count suffix, so clients should treat ETags as opaque version tags and use explicit checksums (CRC32C, SHA-256) for integrity.
- Conditional writes.
If-None-Match: *means "create only if the key does not exist";If-Match: "etag"means "overwrite only if the current version is this one". Both turn the store into something applications can build locks, leases and transactional table formats on. S3 added support for conditional writes in 2024. They require the metadata tier to do an atomic compare-and-set per key. - Listing is ordered. Keys come back in lexicographic (UTF-8 binary) order with a continuation token. That single requirement rules out hash-partitioning the metadata by key, as we will see.
- Range GETs let clients read any byte range, which is how large objects are downloaded in parallel and how analytics engines read only the columns they need from a Parquet file.
Internally, the front ends talk to two private APIs:
# Metadata tier (per key, linearisable)
getCurrent(bucket, key) -> record or not-found
put(bucket, key, record, condition) -> new version id or precondition-failed
list(bucket, prefix, startAfter, limit) -> ordered records
# Data tier (per chunk, immutable)
writeFragment(chunkId, fragmentIndex, bytes, checksum) -> durable ack
readFragment(chunkId, fragmentIndex, offset, length) -> bytes, checksum
deleteFragment(chunkId, fragmentIndex) -> ack (called only by GC)Keeping these two interfaces apart, with nothing but chunk ids crossing between them, is the most important structural decision in the system.
High-Level Design#
We build up in three steps: storing and fetching bytes, surviving failures, and listing and consistency. Then we assemble the full design.
1. Store and fetch objects#
Bad: one server with a big file system
A web server accepts PUT /bucket/key and writes the bytes to /data/bucket/key on its local file system; GET reads the file back. It works for a few terabytes. Then everything breaks at once. The server's disks fill up. One disk failure loses data. One server failure makes everything unavailable. And file systems handle billions of small files badly: each file costs an inode and directory entries, and reading one may take several disk seeks (directory, inode, data), which wastes the scarce random IOPS of hard drives.
Good: many storage servers and one master that knows where everything is
Spread objects over many storage servers, and keep a single master that maps each key to the servers holding it. Clients ask the master where an object lives, then talk to those servers for the bytes. This is the shape of the Google File System (Ghemawat, Gobioff and Leung, SOSP 2003): a single master holding all metadata in memory, with chunkservers storing 64 MB chunks. It scales the bytes well, and having one brain makes placement and consistency easy to reason about.
Its limit is the master. All metadata must fit in one machine's memory, and every open, create and delete goes through it. With 10 trillion objects at 500 bytes each we would need 5 PB of RAM. Google itself moved beyond the single master with Colossus, which shards metadata into a distributed database.
Great: separate the metadata tier from the data tier, and shard both
Split the system into independent tiers, each scaled on its own:
- Front ends: a stateless fleet behind load balancers. They authenticate requests, enforce policies, talk to the metadata tier, and stream bytes to and from data nodes. Clients only ever talk to front ends.
- Metadata service: a distributed, sharded, replicated index from
(bucket, key, version)to an object record: size, checksums, timestamps, and the list of chunk ids and their stripes. Small records, very high request rates, strongly consistent. - Data nodes: thousands of storage servers full of disks. They store immutable fragments by chunk id and know nothing about buckets, keys or users.
- Placement service: knows every data node and disk, its health, free space and position in the failure-domain tree, and decides where new stripes go.
The PUT path writes data first, metadata last:
The metadata commit in step 5 is the commit point. Before it, the new data exists but nobody can see it; if the front end crashes, the fragments are orphans that garbage collection will reclaim. After it, the new version is visible to everyone. Because data is durable before metadata points to it, there is never a moment when a visible object has missing bytes. This "write data, then publish a pointer" pattern recurs everywhere in storage design.
The GET path reverses it: look up the record in the metadata service, find the chunk ids and their fragment locations, read from data nodes, verify checksums, and stream to the client.
Front ends cache the placement map (which disks hold which placement groups), so step 4 is usually a local lookup.
2. Survive disk, server, rack and zone failures#
Bad: one copy on RAID
Hardware RAID inside each server protects against a single disk failure but not against losing the server, its power supply or its rack, and RAID rebuilds of a 20 TB disk take a day or more, during which a second failure is fatal. RAID is a server-level tool; we need cluster-level redundancy.
Good: three replicas in three zones
Write each chunk to three data nodes, one in each availability zone. Any two can fail and the data survives; reads can be served from any replica, ideally the closest. Repair is simple: copy a surviving replica to a new disk. This is how many systems start (HDFS by default, Cassandra, many key-value stores). The cost is 3 times the raw storage: at 1 EB logical, 3 EB of disk instead of under 2 EB. At exabyte scale that difference is hundreds of thousands of drives.
Great: erasure coding for bulk data, replication where it pays
Erasure coding cuts data into k pieces and computes m parity pieces such that any k of the k + m pieces rebuild the original. With k = 10 and m = 4, we store 14 pieces for every 10 pieces of data: 1.4 times overhead, and we survive any 4 failures, which is more than triple replication survives at less than half its overhead. The price is CPU for encoding, more complex reads when pieces are missing, and more expensive repair (to rebuild one lost piece, read k survivors).
The usual production mix:
- Large objects are erasure coded, with fragments spread across zones so the loss of a whole zone still leaves at least k pieces. We size that scheme in the erasure coding deep dive.
- Small objects (a few kilobytes) are either packed together into large chunks and then erasure coded, or replicated, because encoding a 2 KB object into 14 fragments of 150 bytes each would be absurdly inefficient in disk I/O.
- Fresh writes can be replicated first and converted to erasure coding in the background a few hours later, so the write path stays simple and fast and data that is deleted quickly never pays the encoding cost. Facebook's f4 warm storage paper (Muralidhar and colleagues, OSDI 2014) describes this kind of hot-then-warm tiering.
Redundancy is only half of durability. The other half is repair speed: the shorter the window between a failure and its repair, the smaller the chance that more failures pile up in the same stripe. The durability deep dive puts numbers on this.
3. Listing keys and strong consistency#
LIST returns keys in order, by prefix, a page at a time. If the metadata were hash-partitioned by key, the keys photos/2026/03/a.jpg and photos/2026/03/b.jpg would be on random partitions, and listing a prefix would mean asking every partition. So the metadata index is range-partitioned: each partition owns a contiguous range of (bucket, key) space, and a listing reads one or a few adjacent partitions in order. Partitions split when they get too big or too hot, and merge when they cool. See Partitioning and Sharding.
For strong consistency, each partition has one leader that orders all writes to its key range, replicated to followers with a consensus protocol such as Paxos or Raft so that the leader can fail without losing acknowledged writes. Reads of the current version go to the leader (or to a follower that can prove it is up to date). A successful PUT is acknowledged only after its record is committed to a quorum of the partition's replicas, so every later read sees it. See Consistency Models and Leader Election and Coordination Services.
The full high-level design#
The request path and metadata tier:
The data tier and background services:
Components:
- DNS and load balancers. Spread clients across front ends in all zones; bucket-specific DNS names let the system steer traffic per bucket if needed. See Load Balancing.
- Front ends. Stateless; terminate TLS, verify signatures, evaluate bucket policies, compute checksums, erasure-encode on PUT and decode on GET, enforce per-account rate limits. They stream: a 5 GB PUT never sits in a front end's memory. See Rate Limiting and Throttling.
- Auth and policy cache. Keys, users and bucket policies change rarely and are read on every request, so they are cached close to the front ends with short TTLs and push invalidation.
- Metadata router and partitions. A thin layer maps
(bucket, key)to the partition owning that range and forwards to its leader. Each partition is a replicated state machine over a local ordered key-value engine (an LSM tree on SSD is typical). See Storage Engines: B-Trees vs LSM Trees. - Partition map and split manager. Tracks partition boundaries and leaders, splits hot or large partitions, moves partitions between hosts. The map itself is small and kept in a strongly consistent coordination store. See ZooKeeper and etcd.
- Placement service. The cluster's map of disks and failure domains, and the decider of where each new stripe goes. Not on the read path: front ends cache its map.
- Data nodes. Store fragments in large append-only files with an in-memory or SSD index; checksum everything; serve reads with one seek.
- Repair service. Detects lost fragments (failed disks, failed checksums) and rebuilds them elsewhere, most-endangered stripes first.
- Scrubber. Re-reads every fragment on a cycle of weeks, verifying checksums, to catch silent corruption before it meets another failure.
- Garbage collector and compactor. Deletes fragments no longer referenced by any metadata record, and compacts append-only files to reclaim space.
- Lifecycle workers. Apply bucket rules: expire old versions, abort stale multipart uploads, move cold objects to cheaper classes.
Key Flows#
Flow 1: PUT of a 64 MB object, erasure coded#
Notes:
- The front end encodes as it streams; it never buffers the whole object.
- Each fragment write is acknowledged only once it is on stable storage (fsync or equivalent) on the data node.
- The front end waits for enough acks to meet the durability rule, here 12 of 14, so a single slow or failed disk does not stall the PUT. The two missing fragments are recorded, and the repair service fills them in shortly after. Waiting for all 14 would make tail latency hostage to the slowest of 14 disks.
- If the client's checksum does not match what arrived, the PUT fails and the fragments become garbage. Corrupt data never becomes visible.
Flow 2: GET with one data node down (degraded read)#
Because the code is systematic (the k data fragments are the original bytes, unchanged), a normal read just concatenates data fragments with no decoding. Only when a data fragment is slow or missing does the front end read a parity fragment and decode. To cut tail latency, front ends can also hedge: request k + 1 fragments and use the first k that arrive.
Flow 3: multipart upload of a 2 TB object#
Completion copies no data. The final object record simply concatenates the chunk lists of the parts the client named, in order. A 2 TB object completes in milliseconds.
Flow 4: two writers race with conditional writes#
Both writers uploaded their data, but only one record commits; the other's fragments become garbage. Because one partition leader orders all writes to a key, "put if absent" is a simple atomic check inside it.
Data Model#
Two separate stores with nothing in common except chunk ids: the metadata index (who exists, what they consist of) and the placement and fragment maps (where the bytes are).
The metadata side:
The data side:
| Store | Key | Partitioning | Main operations |
|---|---|---|---|
| Bucket table | bucket_name | Small, globally replicated, heavily cached | Resolve bucket to account, region, policy, versioning |
| Object index | (bucket, key, inverted version) | Range-partitioned, Raft-replicated, LSM on SSD | Get current version, put with condition, list by prefix |
| Multipart uploads and parts | (bucket, key, upload_id, part) | Same partition as the target key | Record parts, list parts, complete, abort |
| Placement groups | group_id | Small; held by placement service, cached by front ends | Map group to its k + m disks |
| Stripe and fragment state | chunk_id | On the data nodes themselves, plus a repair index | Which fragments exist, which need repair |
| Disk inventory | disk_id | Placement service | Health, free space, failure domain |
Key design points:
- The object index key is
(bucket, key, inverted version). Inverting the version (for example, a maximum value minus a timestamp-based version id) sorts the newest version of a key first, so "get current version" is a single seek to the first entry with that bucket and key. Listing a prefix is a range scan that skips older versions. - An object record is small and self-describing. It contains everything needed to read the object without consulting another metadata store, except the placement map:
{ "bucket": "media-prod", "key": "videos/raw/9f2.mov", "version": "v7",
"size": 67108864, "etag": "3b1f...-16", "sha256": "c0ffee...",
"storageClass": "STANDARD", "createdAt": "2026-03-02T10:15:00Z",
"chunks": [ { "id": "ch_51a9", "group": "g812", "offset": 0, "length": 41943040 },
{ "id": "ch_51aa", "group": "g813", "offset": 41943040, "length": 25165824 } ],
"userMetadata": { "camera": "A7" } }- Chunk ids are unique, never content hashes. Unlike a sync service, a general object store usually does not deduplicate across customers (it would leak information and complicate deletion). Chunk ids are random or sequence-derived identifiers, and each chunk belongs to exactly one object version or multipart part, which makes garbage collection much simpler.
- Placement is by group, not per chunk. The object record names the placement group of each chunk; the group names its disks. When a disk is replaced, only the group's membership changes. Billions of chunk records are untouched.
- Data nodes are the source of truth for fragments. Each data node knows exactly which fragments it holds, with checksums. A central repair index (fed by heartbeats and scrubbing reports) tracks only exceptions: missing or corrupt fragments.
For the engines behind each store, see Storage Engines: B-Trees vs LSM Trees, Data Modeling and Choosing a Database: A Decision Guide.
Deep Dives#
1. Metadata service vs data nodes: why split them, and how to build the metadata tier#
The metadata tier and the data tier have opposite profiles:
| Property | Metadata | Data |
|---|---|---|
| Size per item | About 500 bytes | Bytes to terabytes |
| Total | Petabytes | Exabytes |
| Access | Random point reads and writes, ordered scans | Large sequential streams, mostly cold |
| Consistency | Linearisable per key | Immutable, so consistency is trivial |
| Medium | SSD or memory | Dense hard drives |
| Bottleneck | Requests per second, latency | Capacity, bandwidth, IOPS per TB |
Putting both in one system forces one to compromise for the other. A single master that tracks everything (the GFS shape) runs out of memory and request capacity; a data node that also tracks object names cannot be replaced without touching namespace state. Splitting them lets each tier use its own hardware, scale on its own axis, and fail independently. A data node failure never touches metadata, and a metadata partition failover never moves bytes.
Basic: a single relational database for metadata
A PostgreSQL or MySQL primary with replicas, holding a table of objects, is perfectly good for a private store of a few hundred million objects. MinIO-style small deployments go further and keep the metadata for each object right beside its data on the same disks, with no separate database at all. At 10 trillion objects and a million writes per second, neither works.
Better: hash-sharded key-value store
Hash (bucket, key) to one of thousands of partitions, each replicated. Writes and point reads scale linearly and load spreads evenly. But LIST breaks: keys with a common prefix are scattered over every partition, and an ordered listing must ask all of them and merge. A store that must list in order cannot be hash-partitioned on key.
Best: range-partitioned, consensus-replicated, auto-splitting index
- Range partitioning. Each partition owns a contiguous slice of the sorted
(bucket, key)space, such as[media-prod/videos/a, media-prod/videos/k). Point lookups route by binary search over partition boundaries; listings scan one partition after another in order. - Replication by consensus. Each partition is a Raft or Paxos group of three to five replicas spread across zones, with one leader ordering writes. A write is durable once a majority has logged it, so a zone loss leaves a majority and the partition elects a new leader in seconds. This is the same technique used by Spanner, CockroachDB, TiKV and other distributed databases. See Database Replication.
- Local engine. Each replica stores its range in an LSM tree on SSD (RocksDB is a common choice). LSM trees absorb high write rates as sequential writes and support ordered scans, which is exactly the workload.
- Automatic splitting. A partition that grows beyond a size limit, or whose request rate exceeds what one leader can serve, splits at a key near its middle (or at the hot spot). The split manager updates the partition map, and routers pick up the new boundaries.
Hot prefixes. Range partitioning has one sharp edge: sequential keys. A customer that writes logs/2026-03-02T10:15:00.001, logs/2026-03-02T10:15:00.002, and so on always writes to the end of the key range, so every write lands on the last partition, however many partitions exist. Splitting does not help, because the new right-hand partition becomes the hot one. Mitigations: split at the hot key so the hot partition is small and can move to a dedicated host; ask customers to put a high-cardinality component early in the key; and scale per prefix. S3 documents a rate of at least 3,500 PUT, COPY, POST or DELETE and 5,500 GET or HEAD requests per second per partitioned prefix, scaling by adding prefixes, which is this mechanism seen from the outside. A sudden burst to a new prefix can see throttling (HTTP 503 "Slow Down") until splits catch up.
Listing with a delimiter. list(prefix="photos/", delimiter="/") should return the files directly under photos/ plus "common prefixes" such as photos/2025/ and photos/2026/ instead of every key beneath them. A naive scan would read millions of keys to report two prefixes. The trick is skip scanning: on encountering photos/2025/a.jpg, emit photos/2025/ as a common prefix, then seek directly to the first key after photos/2025/ plus a byte greater than /. Each common prefix costs one seek, not one entry per key. See Database Indexing.
Caching metadata. Hot objects are read thousands of times per second. Front ends can cache records, but only if the cache can never serve a stale record after an overwrite, since we promised strong consistency. Options: no caching of mutable records at the front end (rely on the partition leader's memory cache); caching with a validation step (ask the leader "is version v7 still current?", which is cheaper than a full read); or leases with invalidation. The consistency deep dive covers how this was done for S3.
How many partitions? With 5 PB of metadata and partitions capped at, say, 10 GB to keep splits and moves fast, the region has on the order of 500,000 partitions. That sounds like a lot, but each is a Raft group of a few small replicas, and hundreds of them share one SSD-heavy server. More, smaller partitions make load balancing, recovery and splitting finer-grained.
2. The data node: storing billions of fragments on hard drives#
A data node receives "write fragment X", "read bytes 0 to 4 MB of fragment Y", "delete fragment Z" and must do them with as few disk seeks as possible, never return corrupt data, and survive crashes at any instant.
Bad: one file per fragment on a general file system
Simple, but each read costs a directory lookup, an inode read and the data read: up to three seeks on a hard drive. File systems also struggle with hundreds of millions of files per disk (inode tables, directory sizes, fsck times). Facebook's paper "Finding a Needle in Haystack: Facebook's Photo Storage" (Beaver and colleagues, OSDI 2010) describes exactly this problem with photos stored as files on NAS: metadata lookups, not data reads, dominated disk I/O.
Good: large append-only volume files with an in-memory index
Haystack's answer: append many objects ("needles") into one huge volume file of about 100 GB, and keep an in-memory index from object id to (offset, size) in that file. A read is one seek and one sequential read. A write is an append. A delete is a flag in the index plus a tombstone record in the file. The index can be rebuilt by scanning the volume after a crash, or loaded quickly from a periodically written index checkpoint.
Best: a purpose-built, log-structured fragment store with checksums everywhere
Production object stores build their own on-disk engines on this idea, adding:
- Checksums on every record, verified on every read and by background scrubbing. A mismatch means the fragment is reported lost and rebuilt from the stripe.
- Write-ahead ordering and crash consistency. Data is appended and flushed before the index points to it, so after a crash the index never refers to garbage. Exactly the same "data first, pointer last" rule as the global write path.
- An index on SSD or in memory, so lookups do not consume disk seeks.
- Compaction. Deletes leave holes in append-only files. A background process copies live fragments out of mostly empty files into new ones and frees the old files. It needs headroom and I/O budget, and its pace is a cost-versus-space trade-off.
- Direct disk management. Bypassing a general-purpose file system (raw block device access, or a minimal file system with large preallocated files) avoids double buffering and journalling overhead.
AWS published a paper on the storage node software used in S3, ShardStore: "Using Lightweight Formal Methods to Validate a Key-Value Storage Node in Amazon S3" (Bornholt and colleagues, SOSP 2021). It describes a key-value store per disk, written in Rust, structured as a log-structured merge tree whose data lives in large extents, with crash consistency guaranteed by tracking dependencies between writes, and validated with property-based testing and model checking against a reference model. The paper's lesson is as important as its design: at this scale, the on-disk engine is where subtle bugs lose data, and it deserves the strongest verification tools you can afford.
Small objects. A 2 KB object erasure-coded on its own would create 14 fragments of about 150 bytes each, so a GET would issue many tiny disk reads. Instead, small objects are packed: front ends (or an intermediate tier) gather many small objects into one chunk of several megabytes, and that chunk is erasure coded as a unit. Because the code is systematic, each small object lies within one data fragment, so a GET reads one fragment from one disk. One seek, as the IOPS budget requires. The cost: deleting a small object leaves a hole that only compaction can reclaim.
Heat. Some data is hot (yesterday's uploads, a viral video), most is cold. If all of today's writes land on today's newly added empty disks, those disks become the hottest in the fleet, and their IOPS saturate while old disks idle. Placement must therefore spread new data across all disks, not just empty ones, and a background rebalancer moves data to even out both fullness and heat. Large fleets with millions of independent workloads benefit from statistics: individual customers' load is spiky, but the aggregate over a whole disk becomes smooth once each disk holds tiny pieces of very many customers' data.
3. Placement and replication: where the pieces go#
Redundancy only helps if the copies or fragments fail independently. Two replicas on the same server, or in the same rack under the same power feed, are one failure away from both being gone. Placement is the discipline of spreading pieces so that no plausible single event takes out too many of them.
Failure domains
Model the region as a tree: region > availability zone > room or row > rack > server > disk. Each level is a failure domain: a disk fails alone; a server takes its 60 disks; a top-of-rack switch or power distribution unit takes the whole rack; a zone can lose power, cooling or network as a unit. Placement rules are written against this tree, for example:
- No two fragments of a stripe on the same server.
- No two fragments of a stripe in the same rack.
- At most a fixed number of fragments of a stripe per zone, chosen so that losing one entire zone still leaves at least k fragments.
Basic: random placement per chunk
Pick k + m random disks satisfying the rules for every new chunk. Load spreads beautifully and repair is massively parallel: when a disk dies, its fragments belong to stripes spread over thousands of other disks, so thousands of disks each rebuild a little. But there is a subtle cost. With billions of stripes placed at random, almost every combination of a few disks holds some stripe. When any m + 1 disks fail at the same time (say, a rack-wide power event plus a few unlucky disks elsewhere), it is very likely that some stripe had all its lost pieces on exactly those disks. Random placement makes data loss events rare in volume but frequent in occurrence.
Better: placement groups (copysets)
Choose a limited set of disk groups up front, and place every stripe on one of those groups. A disk belongs to several groups, but the number of distinct groups is much smaller than the number of possible combinations. Then losing m + 1 random disks loses data only if they happen to be in the same group, which is far less likely. "Copysets: Reducing the Frequency of Data Loss in Cloud Storage" (Cidon and colleagues, USENIX ATC 2013) analyses this trade-off: fewer groups mean fewer loss events, but when one happens it loses more data, and repair is less parallel because each disk shares groups with fewer partners. Ceph's placement groups and its CRUSH algorithm (Weil and colleagues, SC 2006), which computes placement deterministically from a cluster map and rules, are a widely used realisation of group-based placement.
Best: groups with a tuned scatter width, plus active rebalancing
Choose the number of groups so that each disk shares groups with enough partners (its scatter width) to make repair fast, but no more. A disk with a scatter width of 100 can be rebuilt by 100 disks reading in parallel. Then:
- New stripes go to groups with free space and low heat, respecting failure-domain rules.
- When a disk fails, each affected group gets a replacement disk; the group's stripes are rebuilt onto it from the survivors.
- When capacity is added, new disks join new groups, and a rebalancer migrates some stripes from full groups to new ones, throttled so it does not starve foreground traffic.
- When hardware is retired, its groups are drained first, then the disks are removed. Draining before removal is the same as repair but without the urgency.
Replication across zones
Even with erasure coding inside the stripe, the cross-zone layout decides what a zone outage means. Two common shapes:
- One stripe spans all three zones (the diagram above): any zone can be lost and all data remains readable directly. Cost: every PUT sends fragments across zones (cross-zone bandwidth is precious), and the code must have enough parity to survive losing a third of its fragments, which raises overhead (the next deep dive derives roughly 1.5 to 1.8 times).
- A stripe lives inside one zone, plus a cross-zone copy or cross-zone parity. Facebook's f4 kept Reed-Solomon stripes within a data centre and added an XOR of blocks from two data centres, stored in a third, so any one data centre could be lost. The paper reports an effective replication factor of 2.1, against 3.6 for its earlier replicated Haystack storage.
For metadata, replication is simpler: each partition is a consensus group with replicas in every zone.
4. Erasure coding: how it works and how to choose a scheme#
The idea in one example
Take two numbers, a = 5 and b = 7. Store a, b and their sum p = a + b = 12 on three disks. Lose any one disk, and you can recompute it: a = p minus b, b = p minus a. That is a (2, 1) erasure code, 1.5 times overhead, surviving one failure. RAID 5 does exactly this with XOR instead of addition.
To survive more failures we need more independent equations. With k data values, compute m parity values, each a different weighted sum of the data. If every set of k of the k + m values determines the data (any k equations are linearly independent), then any m losses are survivable. Reed-Solomon codes (Irving Reed and Gustave Solomon, "Polynomial Codes over Certain Finite Fields", 1960) achieve exactly this. One way to see it: treat the k data values as the coefficients of a polynomial of degree k minus 1; evaluate it at k + m distinct points; store the evaluations. Any k evaluations determine a polynomial of degree k minus 1 uniquely (two points determine a line, three a parabola), so any k surviving fragments recover the data.
The arithmetic is done not over ordinary integers (whose sums would grow and overflow) but over a finite field, typically GF(2^8): 256 values, one per byte, with addition being XOR and multiplication done by lookup tables or by CPU vector instructions. Every result is still one byte, so a fragment is exactly as big as a data piece. Libraries such as Intel's ISA-L encode at several gigabytes per second per core using SIMD instructions, so encoding CPU is not the bottleneck it once was.
Codes used in storage are systematic: the first k fragments are the original data unchanged, and only the m parity fragments are computed. Normal reads therefore need no decoding at all.
Choosing k and m
Overhead is (k + m) / k. Tolerated failures is m. The design space:
| Scheme | Overhead | Survives | Repair reads per lost fragment | Notes |
|---|---|---|---|---|
| 3 replicas | 3.0x | 2 losses | 1 | Simplest; fast reads and repair |
| RS(6, 3) | 1.5x | 3 losses | 6 | Hadoop 3 HDFS default erasure policy |
| RS(10, 4) | 1.4x | 4 losses | 10 | Used in Facebook's f4 |
| RS(17, 3) | 1.18x | 3 losses | 17 | Backblaze Vaults, spread over 20 storage pods |
| RS(12, 6) across 3 zones | 1.5x | 6 losses or 1 zone | 12 | 6 fragments per zone; a zone loss leaves exactly 12 |
| RS(12, 9) across 3 zones | 1.75x | 9 losses, or 1 zone plus 2 more | 12 | 7 fragments per zone; margin after zone loss |
Two forces pull in opposite directions:
- Larger k lowers overhead, but each read of a whole object touches more disks, each repair reads more data, and the stripe spans more failure domains. Small objects split k ways become tiny fragments, which is why small objects are packed first.
- Larger m improves durability and lets reads succeed with more disks slow or missing, at the cost of overhead.
Zone tolerance drives the overhead. If a stripe of n = k + m fragments is spread evenly over 3 zones, losing a zone removes n / 3 fragments, so we need m at least n / 3, which means k at most 2n / 3 and overhead at least 1.5 times. And at exactly 1.5 times, a zone outage leaves zero margin: one more disk failure anywhere in the stripe during the outage makes the data unreadable until the zone returns. Adding margin pushes overhead toward 1.7 to 1.8 times. That is the 1.8 we used in the estimate. Systems that cannot afford that overhead keep stripes within a zone and accept that a zone outage makes some data temporarily unavailable (not lost), or use cross-zone XOR as f4 did.
Repair cost and local reconstruction codes
With RS(12, 6), rebuilding one lost fragment reads 12 fragments: 12 times the data rebuilt, across the network. Since most failures are single-fragment losses, this dominates repair traffic. Local Reconstruction Codes fix the common case. Microsoft's "Erasure Coding in Windows Azure Storage" (Huang and colleagues, USENIX ATC 2012) describes LRC(12, 2, 2): 12 data fragments split into two local groups of 6, each with its own local parity, plus 2 global parities. A single lost fragment is rebuilt from its local group of 6 instead of 12 fragments, halving repair reads, while 16 total fragments (1.33 times overhead) still survive any 3 failures and many patterns of 4. The theory of the trade-off between storage and repair bandwidth was laid out in "Network Coding for Distributed Storage Systems" (Dimakis and colleagues, IEEE Transactions on Information Theory, 2010), which introduced regenerating codes.
Where to encode
- In the front end, on the write path (as in our Flow 1): no extra copies, but the PUT pays encoding latency and cross-zone fan-out, and very fresh data that will be deleted soon pays for encoding it does not need.
- Replicate first, encode later: write 3 replicas synchronously; a background job encodes sealed extents into stripes and deletes the replicas. Faster, simpler writes; temporary 3 times overhead on fresh data; extra I/O for the conversion. Many systems with append-oriented extents work this way, encoding once an extent is full and sealed.
5. Durability math: what eleven nines really means#
The definition. Annual durability of 99.999999999 percent means the probability that a given object is lost in a year is 10^-11. AWS illustrates its S3 design target this way: store 10 million objects and you can expect, on average, to lose one object once every 10,000 years (10^7 objects x 10^-11 per year = 10^-4 objects per year). Across a region of 10 trillion objects, the same target would allow about 100 objects lost per year in total. The engineering goal is to make the real number far lower than the target.
The three ingredients. Data is lost when more pieces of one stripe fail than the code can tolerate, before repair completes. So durability depends on:
- Failure rate of each piece: the annualised failure rate (AFR) of disks, about 1 to 2 percent, plus server and rack failures.
- Redundancy: how many simultaneous losses a stripe survives (2 for three replicas, m for an erasure code).
- Window of vulnerability: the time from a failure to the end of its repair, made of detection time plus rebuild time.
A worked model. Assume independent disk failures with AFR = 1.5 percent and a repair window T. The chance that a particular disk fails during a window of T hours is about p = 0.015 x T / 8,760.
Three replicas, T = 24 hours. p is about 4.1 x 10^-5. A stripe is lost if, after a first failure, the other two replicas both fail within the window. First failures in a given three-replica set happen at a rate of about 3 x 0.015 = 0.045 per year. The chance that both others then fail in the window is about 2p^2 (one fails during the window, then the last fails during its repair), roughly 3.4 x 10^-9. Annual loss probability: 0.045 x 3.4 x 10^-9, about 1.5 x 10^-10. That is just under ten nines, short of eleven.
Three replicas, T = 1 hour. p is about 1.7 x 10^-6, 2p^2 about 5.8 x 10^-12, annual loss about 2.6 x 10^-13: nearly thirteen nines. Cutting the repair window 24 times improved durability by a factor of about 600, because the window appears squared. With an erasure code tolerating m failures, it appears to the power m. Repair speed is as important as redundancy.
RS(12, 6), T = 24 hours. Eighteen fragments, loss needs seven concurrent failures. The rate is roughly 18 x 0.015 x C(17, 6) x p^6, with C(17, 6) = 12,376 ways to choose the other six, which comes to around 10^-23 per year (the more careful Markov model in the deep dive at the end of this page gives about 10^-20): over twenty nines either way. Under independence, a good erasure code makes disk-failure data loss essentially impossible.
Why the real number is not twenty nines. The independence assumption is false, and the real risks are the correlated ones:
- Correlated hardware failures. Drives from the same manufacturing batch, installed on the same day in the same rack, tend to fail together. Power events, cooling failures and firmware bugs hit many disks at once. Placement mixes batches and models across groups for this reason.
- Zone and site events. Fire, flood or a long power outage at one facility. Covered by cross-zone placement.
- Latent errors. A sector that went bad months ago is discovered only when it is read during a repair. The "redundant" fragment you were counting on was already gone. Scrubbing (re-reading everything on a cycle of a few weeks) bounds how long such errors can hide.
- Software bugs. A bug in the storage engine, the repair logic or garbage collection can destroy data on every replica at once, because every replica runs the same code. This is the largest real risk in a mature system, and the reason for formal methods, staged deployments, deletion delays and invariant checks.
- Operator error. A mistyped command that decommissions the wrong racks. Guardrails: tooling that refuses operations that would drop any stripe below its safety margin.
The useful view, then: the independent-failure math tells you how much redundancy and repair speed you need; the rest of the engineering is about removing correlation, because that is where data is actually lost.
Making repair fast. Detection takes time: a disk that stops responding might be rebooting. Declare it dead too early and you trigger an unnecessary repair storm; too late and the window grows. A typical approach waits minutes, not hours, and prioritises by risk: stripes that have lost two fragments are repaired before stripes that have lost one. Rebuild speed comes from declustering: because a failed disk's fragments belong to stripes spread over many partner disks, many disks rebuild in parallel. A 20 TB disk rebuilt onto a single replacement at 200 MB/s takes about 28 hours; spread across 200 partners at 50 MB/s each (10 GB/s combined), it takes about 33 minutes. Declustered repair is what makes the T = 1 hour line above realistic.
6. Consistency: from eventual to strong read-after-write#
For its first fourteen years, S3 offered read-after-write consistency for new objects but only eventual consistency for overwrites, deletes and listings: after overwriting a key, a GET might briefly return the old version, and a new object might not appear in a LIST for a while. Applications (notably big-data tools that used S3 as a file system) built elaborate workarounds, such as a separate consistent metadata table. In December 2020, AWS made all S3 operations strongly consistent, at no extra cost and with no performance penalty. How you get there is a good deep dive.
Where staleness comes from
Strong consistency is easy with one copy and no caches. Staleness creeps in because of:
- Replicas: a read served by a follower that has not yet applied the latest write.
- Caches: front ends or a metadata cache serving a record that has since been overwritten.
- Secondary indexes: a listing index updated asynchronously from the primary object index.
- Negative caching: a cache remembering "not found" for a key that has since been created.
Basic: eventual consistency everywhere
Writes go to the partition leader; reads go to any replica or cache; caches expire after a TTL. Fast and highly available, but every staleness source above is visible to clients.
Better: all reads through the partition leader
Every GET, HEAD and LIST goes to the leader of the relevant partition, which by definition has every committed write. Consistency is now strong, but each leader serves all reads for its range, front-end caches are useless, and reads from other zones pay cross-zone latency. A leader must also be sure it is still the leader (another may have been elected during a network partition). It confirms this with a lease, a time-bounded promise from a majority that no other leader will be elected before it expires, or by checking with a majority before answering (Raft's "read index" approach).
Best: consistent caches and follower reads, validated cheaply
Keep the caches and follower reads, but make them prove they are current:
- Each partition leader assigns every write a sequence number, monotonically increasing within the partition.
- A follower can answer a read only once it has applied writes up to the leader's current commit index (obtained by a cheap round trip, or carried in a lease).
- A cache entry carries the sequence number of the record it holds. Before serving it, the front end asks a lightweight, highly available component "what is the latest sequence for this key?". If the cached sequence matches, the entry is good; if not, it is refetched. Checking a sequence number is far cheaper than reading the whole record, and can be batched.
AWS has described the S3 change in broadly these terms in public posts and talks: a new replicated component (they called it a witness) that tracks the most recent write for each object, so that cached metadata can be checked for staleness, together with changes to the replication logic and extensive formal verification of the new protocol. We present the mechanism above as a reconstruction of the idea, not as S3's exact internals.
The remaining semantics
- Concurrent PUTs to one key. Both are accepted; the leader orders them; the later-ordered one becomes current, and with versioning on, both versions are kept. "Later" means later in the leader's order, not by client clock, so there is always a single answer. To get anything stronger than last-writer-wins, clients use conditional writes.
- Conditional writes.
If-None-Match: *andIf-Match: "etag"are compare-and-set operations executed by the partition leader, atomically. They let clients build locks, leases and optimistic transactions on top of the store; open table formats such as Apache Iceberg and Delta Lake rely on atomic "put if absent" or similar primitives to commit table snapshots safely. - LIST. In our design, listings read the same range-partitioned index as GETs, so they are consistent with it. If a design uses a separate listing index, it must be updated in the same transaction or be validated like a cache.
- Deletes. A DELETE commits a tombstone (or, with versioning, a delete marker) through the leader; subsequent GETs return 404. The bytes are reclaimed much later by GC, which never affects visibility.
- Cross-region replication is asynchronous: a replica bucket in another region lags by seconds to minutes. Strong consistency is a per-region promise.
Data itself needs no consistency protocol at all: fragments are immutable and identified by unique chunk ids, so there is never an "old" and "new" version of the same fragment. All the hard consistency work is in the metadata tier, which is one more benefit of separating the two. See Consistency Models and Quorums and Leaderless Replication.
7. Multipart upload: large objects without large failures#
A 50 GB upload over a single HTTP request is fragile: one network blip at 49 GB and the client starts over. Throughput is also limited to one TCP connection, perhaps 100 to 500 MB/s at best from a well-connected server, much less from a laptop. Multipart upload fixes both.
The protocol.
- Initiate:
POST /bucket/key?uploadsreturns anuploadId. The metadata tier records a MULTIPART_UPLOAD row in state "open". No bytes yet. - Upload parts:
PUT /bucket/key?partNumber=N&uploadId=...for each part, in any order, in parallel, from any number of machines. Each part is stored like a small object: erasure-coded, placed, and recorded as a PART row with its size, checksum and chunk references. S3's limits are a good reference: part numbers 1 to 10,000, each part 5 MiB to 5 GiB (the last part may be smaller). Re-uploading the same part number replaces the earlier one. - Complete:
POST ...?uploadId=...with the ordered list of (part number, ETag). The metadata tier checks that each listed part exists with a matching ETag, then in one metadata transaction creates the OBJECT_VERSION whose chunk list is the concatenation of the parts' chunk lists, and marks the upload "completed". Parts not named in the list become garbage. - Abort:
DELETE ...?uploadId=...marks the upload aborted; its parts become garbage.
The key insight: completion copies nothing. The object's bytes already sit on data nodes as the parts' fragments. Completing a 5 TB upload is a metadata write of a few thousand chunk references, taking milliseconds. This is the same "data first, then metadata commit point" pattern as a single PUT, stretched over hours. Until Complete commits, GETs on the key see the previous version (or 404), so a half-finished upload is never visible.
Why parts have a minimum size. Each part is at least one stripe with its own metadata. Thousands of 10 KB parts would bloat metadata and produce tiny stripes. A 5 MiB minimum keeps per-part overhead negligible. With 10,000 parts, the largest object needs parts of at least 500 MB each for 5 TB, so clients choose part sizes from the expected object size (SDKs do this automatically).
Throughput math. A 100 GB upload in 100 MB parts is 1,000 parts. With 16 parallel streams at 60 MB/s each, aggregate throughput is about 960 MB/s and the upload takes under 2 minutes, versus nearly 28 minutes on a single 60 MB/s stream. A failed part costs one 100 MB retry, not a restart. The same idea works in reverse for downloads: ranged GETs (Range: bytes=...) fetch chunks of a large object in parallel, and the data tier serves each range from just the stripes that contain it.
ETags and checksums. For a single PUT, the ETag of an unencrypted object has commonly been the MD5 of its bytes. For a multipart object, the ETag is commonly observed to be a hash over the parts' hashes with a "-N" suffix giving the part count, so it is not the MD5 of the whole object. Clients must not compare it with a local MD5. Modern S3 lets clients send stronger checksums (CRC32, CRC32C, SHA-1, SHA-256, and CRC64NVME in newer releases); for multipart uploads, the stored checksum can be a composite (a checksum of the part checksums) or, for some CRC algorithms, a full-object checksum, since CRCs can be combined mathematically from part CRCs without re-reading the data. The design point: verify integrity end to end, per part on upload and per chunk on every read, with checksums the client computed before the bytes ever left its memory.
The orphan problem. Uploads that are initiated and never completed or aborted leave parts consuming storage forever, and they are invisible in normal listings. A lifecycle rule such as "abort incomplete multipart uploads after 7 days" is the standard fix, and a well-run store recommends it by default. Internally, a sweeper scans open uploads by age.
The diagram simplifies: in practice the client sends each part to a front end, which encodes and places it and records the PART row in metadata.
8. Garbage collection: reclaiming bytes safely#
Bytes become garbage in four ways:
- Deletes: a DELETE (without versioning) or a permanent version delete removes the metadata record; the chunks it pointed to are now unreferenced.
- Overwrites: without versioning, a PUT to an existing key makes the old version's chunks unreferenced.
- Aborted or expired multipart uploads: parts never stitched into an object.
- Failed PUTs: the front end wrote fragments to data nodes, then crashed or timed out before the metadata commit. These fragments were never referenced by anything.
Deleting the wrong chunk is the one mistake an object store cannot undo, so GC is designed around safety first and efficiency second.
Bad: delete the bytes synchronously on DELETE
The DELETE handler removes metadata, then deletes each chunk from data nodes. It fails on the hard cases: a crash between the two steps leaks chunks forever; failed PUTs are never cleaned up because no DELETE ever arrives for them; and deleting on the request path couples request latency to slow disks.
Good: reference counting
Each chunk carries a count of metadata records pointing at it; it is deleted when the count reaches zero. Without deduplication, every chunk has exactly one owner, so this degenerates to "owner record gone". The trouble is that the count lives on the data side while references live on the metadata side, and keeping them in step across two systems needs a distributed transaction for every write. Lost decrements leak space, and an extra decrement destroys live data. Failed PUTs still never get a count.
Great: mark and sweep with a grace period
Treat the metadata tier as the single source of truth for what is live, and reconcile against it:
- Mark. Periodically, scan the metadata index (partition by partition) and produce the set of chunk ids that are referenced, together with a snapshot time.
- Sweep. Each data node lists the chunks it stores. Any chunk not in the live set and older than a safety delay (for example 24 to 72 hours, much longer than any in-flight PUT could take) is a candidate.
- Soft delete. Candidates are marked deleted but kept for a further period. If a later reconciliation finds a reference (from a bug, a race or a restore), they are revived.
- Reclaim. After the soft-delete window, space is actually freed, usually by compaction.
The safety delay solves the race that makes GC hard: a PUT in flight has written fragments but not yet committed metadata. Without the delay, the sweeper would see unreferenced fragments and delete them, and then the PUT would commit a record pointing at nothing. With the delay, any fragment younger than the longest possible PUT is untouchable.
Comparing two huge sets efficiently uses the partitioning that already exists: chunk ids embed their placement group, so marks can be bucketed by group and sent to the data nodes of that group. Bloom filters (see Probabilistic Data Structures for Big Data) can summarise the live set compactly; a false positive just keeps a dead chunk one more cycle, which is safe, while a false negative can never happen with a Bloom filter, which is what makes it safe for this use.
Compaction. If chunks live in large append-only extents or volumes (deep dive 2), deleting a chunk only marks a range dead. The space comes back when a compactor copies the live chunks of a mostly dead extent into a new one and frees the old. The usual policy is to compact extents whose live fraction drops below a threshold such as 50 to 70 percent. The trade-off is write amplification versus wasted space: aggressive compaction rewrites data many times; lazy compaction leaves disks full of dead bytes. Compaction must also preserve placement and erasure-coding rules, so it often works on whole stripes. This is the same tension as compaction in LSM trees, covered in Storage Engines: B-Trees vs LSM Trees.
How much churn? If 2 percent of a 1 EB store is deleted or overwritten per month, GC must reclaim 20 PB per month, about 670 TB a day, which is close to the 900 TB a day of failure repair in the capacity section. Background traffic (repair, scrubbing, compaction, rebalancing) is a first-class workload that needs its own capacity budget and throttles.
9. Repair, scrubbing and failure detection#
Durability math (deep dive 5) assumes failures are detected and repaired quickly. That is the job of a family of background services.
Failure detection. Data nodes send heartbeats to a cluster manager every few seconds and report disk health (SMART counters, I/O errors, latency outliers). States are deliberately graded:
- Healthy.
- Suspect: missed heartbeats or rising errors. Reads avoid it where possible; no repair yet.
- Down (temporary): unreachable, but likely to return (a reboot, a kernel upgrade, a top-of-rack switch flap). Writes go to other members; reads reconstruct from parity; no repair is started for a grace period such as 15 to 30 minutes.
- Lost: past the grace period, or confirmed dead. Repair begins.
The grace period matters at scale. A planned rolling reboot of a rack takes many disks offline for ten minutes; treating every one as lost would launch petabytes of needless repair. On the other hand, a rack that loses power has many disks lost at once, and those stripes are now closer to the edge. The trade-off is set by the code's margin: with RS(12, 6), waiting 30 minutes with one fragment missing is very safe; with three replicas and one already lost, it is not.
Repair prioritisation. The repair scheduler does not process failures in arrival order. It ranks stripes by remaining margin: an RS(12, 6) stripe that has lost four fragments (two left) jumps ahead of a million stripes that have lost one. This is often implemented as a set of queues, one per number of missing fragments, served in strict priority order. During a big event, the most endangered data is safe within minutes even if full recovery takes days.
Repair mechanics. Reconstructing one lost fragment of RS(12, 6) means reading 12 surviving fragments and decoding, so repair reads 12 times the data it rebuilds. This is the main cost of erasure coding, and why LRC codes (deep dive 4) exist. Repair work is spread across many workers and many source disks (declustering), throttled so that customer latency stays within SLO, and given a guaranteed minimum share so that it cannot be starved by peak traffic.
Repair storms. When a whole rack or zone goes down, the volume of missing fragments jumps by orders of magnitude. If everything is repaired at once, the network saturates, foreground latency explodes and new failures (overloaded nodes timing out) can cascade. Defences: grace periods for correlated events (a whole zone failing is almost always temporary, so wait longer before repairing it), rate limits on repair traffic per zone, and reconstructing reads on demand while the backlog drains.
Scrubbing. Bits rot silently: a sector becomes unreadable, or a firmware bug returns wrong data. Background scrubbers re-read every fragment on a cycle of a few weeks, verify checksums, and enqueue repair for anything that fails. Scrubbing a 20 TB disk at a throttled 20 MB/s takes about 12 days, so a two to four week cycle is realistic. Without scrubbing, latent errors accumulate until a repair needs the bad fragment and discovers it is gone.
Auditing. Beyond checksums, a mature store runs end-to-end audits: sample objects, read them through the full GET path, and compare with checksums stored at upload time. Others check invariants such as "every live metadata record points at chunks that exist with enough fragments" and "no stripe has two fragments in the same failure domain". These catch bugs that per-fragment checks cannot, such as metadata pointing at the wrong chunk.
10. Versioning, lifecycle and storage classes#
Versioning
With versioning enabled on a bucket, a PUT never replaces anything: it adds a new version with a fresh version id, and the newest becomes "current". A DELETE without a version id does not remove data either; it adds a delete marker, a special version meaning "this key is deleted". GET on the key then returns 404, but every earlier version can still be read by version id, and deleting the delete marker "undeletes" the object. Only a DELETE that names a specific version id permanently removes that version.
In the metadata index, versions of a key sort together with the newest first, which is why the data model stores the version id in an inverted, time-ordered form (data model section). "Get current" is then a seek to the first entry for the key; "list versions" is a range scan. Versioning protects against the most common causes of data loss in practice: application bugs and humans running the wrong delete. Its cost is storage: every overwrite keeps the old bytes, so versioned buckets usually pair it with a lifecycle rule that expires non-current versions after N days.
Two related protections:
- Object Lock (write once, read many): a version cannot be deleted or overwritten until a retention date, or while a legal hold is set. In compliance mode not even the account's administrator can shorten the retention. Regulated industries use this for records retention, and it is a strong defence against ransomware that deletes backups.
- MFA delete: permanent version deletes require a second factor from the bucket owner.
Lifecycle rules
A lifecycle configuration is a list of rules, each with a filter (prefix, tags, size) and actions: transition to a cheaper class after N days, expire current versions after N days, expire non-current versions, abort incomplete multipart uploads. Lifecycle is executed by background scanners, not on the request path. A daily job walks each bucket's index, evaluates rules, and enqueues transitions and expirations. At 10 trillion objects, that is over 100 million objects evaluated per second if done daily in one pass, so the scan is partitioned the same way as the index and runs continuously. Evaluation is approximate in time (an object may expire some hours after its due date), and well-designed systems say so in their contract.
Storage classes
Different data has very different access patterns. Logs from last week are read often; logs from three years ago almost never, yet must be kept. Storage classes trade cost for access speed, availability or redundancy:
| Class (S3 name) | Design idea | Typical use | Notable constraint |
|---|---|---|---|
| Standard | Multi-zone EC on HDD, warm caches | Active data | Highest storage price |
| Express One Zone (2023) | Single zone, faster media, special directory buckets | Latency-sensitive analytics and ML | Not zone-redundant |
| Standard-IA, One Zone-IA | Same media, priced for rare access | Backups, older data | Per-GB retrieval fee, 30-day minimum |
| Intelligent-Tiering | Moves objects between tiers by observed access | Unknown or changing patterns | Small monitoring fee per object |
| Glacier Instant Retrieval | Archive pricing, millisecond reads | Rarely read but needed fast | Higher retrieval fee |
| Glacier Flexible Retrieval | Cold media, restore before reading | Archives | Minutes to hours to restore |
| Glacier Deep Archive | Cheapest, coldest | Compliance archives | Restores within about 12 hours (bulk up to 48) |
How the cheap classes are built is not fully public, so we describe the general techniques rather than AWS's internals:
- Wider, cheaper codes. Cold data can use wider stripes (lower overhead) because it is rarely read and slower repair is acceptable.
- Denser, slower media. High-capacity shingled magnetic recording (SMR) drives, drives that are mostly spun down, or tape libraries. Spun-down drives and tape explain "restore before read": the data must be staged onto warm disks first.
- Batching. Restores are queued and grouped by physical location (the same tape, the same drive set), which is why bulk restores are cheapest and slowest.
Transitions are themselves a copy: read the object from the warm tier, write it into the cold tier, then switch the metadata pointer, then garbage-collect the warm copy. Minimum storage durations (30, 90 or 180 days depending on class) exist partly because each transition has a real cost.
11. Hot spots and request scaling#
An object store must absorb skew it cannot predict: a viral image, a data-science job opening 50,000 files under one prefix, a backup system writing millions of objects with timestamp-prefixed keys.
Hot partitions in the metadata index. Because the index is range-partitioned by key, sequential key names (such as logs/2026-12-03/...) concentrate writes at the end of one range. The mechanisms from deep dive 1 apply: a partition that exceeds its load threshold splits at a key in the middle of its traffic, not of its data, and the halves move to different nodes. Splits take seconds to minutes, so a sudden spike briefly exceeds capacity, and the front end returns 503 Slow Down to throttle clients, who must retry with exponential backoff and jitter. S3 documents per-prefix rates of at least 3,500 writes and 5,500 reads per second, with no limit on the number of prefixes, and AWS stated in 2018 that customers no longer need to randomise key prefixes to get high throughput. Older advice to put a hash at the start of keys predates that change.
Hot objects. One object being read 100,000 times a second cannot be fixed by splitting: it is one key and one stripe. Options, roughly in order:
- A CDN or edge cache in front of the bucket (see Content Delivery Networks (CDN)) for public or semi-public content. This is the right answer for most "viral" cases.
- Front-end and metadata caches. Metadata for a hot key is cached on many front ends, validated by sequence number (deep dive 6).
- Hot-data caches near the data tier. Small hot objects are kept in memory or on SSD caches on storage or front-end hosts.
- Spreading reads across fragments. For a systematic code, any k of the k + m fragments can serve a read; for a replicated hot object, any replica. A hot stripe can also be temporarily given extra replicas.
The front-end fleet. Front ends are stateless and horizontally scaled behind load balancers; DNS for the regional endpoint spreads clients across many addresses. At roughly 1,000 requests per second per core (signature checks, policy evaluation, routing, encoding and streaming bytes), 5 million requests per second needs about 5,000 cores, or roughly 160 servers of 32 cores. With headroom to lose a zone and absorb spikes, plan on several hundred front-end servers per region; each then streams a few Gbps of the 2.8 Tbps peak egress, well within a 25 Gbps NIC. Clients get more throughput by opening many connections: each connection might move 50 to 100 MB/s, and large-object reads run tens of connections in parallel with ranged GETs.
Admission control. Each tier sheds load before it falls over: per-account and per-bucket request rate limits, per-partition concurrency limits, queue-time budgets (reject requests that have already waited longer than they could be useful), and priority between customer traffic and background traffic. See Rate Limiting and Throttling and Resilience Patterns: Timeouts, Retries and Circuit Breakers.
Tail latency. With a GET touching k data nodes, the slowest of k determines latency. If each node has a 1 percent chance of a 100 ms stall, a read needing 12 nodes stalls about 11 percent of the time (1 - 0.99^12). Two techniques bound the tail: read k + 1 or k + 2 fragments and decode from the first k to arrive, and hedged requests, which send a backup request if the first has not answered within the 95th-percentile latency. Both trade a few percent more disk reads for a much flatter tail, an idea described by Jeffrey Dean and Luiz André Barroso in "The Tail at Scale" (Communications of the ACM, 2013).
12. Security and multi-tenancy#
An object store holds the most sensitive data of millions of customers on shared hardware. Security is not a feature; it is half the design.
Authentication: request signing. Clients do not send a password. They sign each request with a secret key using AWS Signature Version 4 (SigV4): build a canonical form of the request (method, path, sorted query, chosen headers, payload hash), then compute an HMAC-SHA256 with a key derived from the secret, date, region and service. The front end recomputes the signature with its copy of the derived key and compares. Properties: the secret never travels over the network; a signature is only valid for that request and a short time window (protecting against replay); and a leaked derived key is scoped to one day, region and service. Presigned URLs move the signature into the query string so a browser can GET or PUT one object without credentials, valid for a set time (up to 7 days for SigV4). This is the standard way to let users upload directly to the store without routing bytes through your servers; see Pattern: Handling Large Files and Blobs.
Authorization: policies evaluated per request. Several policy types combine: identity policies (what this user or role may do), bucket policies (who may access this bucket), access points (named entry points with their own policies), organisation-wide guardrails, and legacy ACLs. The evaluation rule is simple: an explicit deny anywhere wins; otherwise something must explicitly allow; otherwise the request is denied. Policies are evaluated on every request in the front end, so they are compiled and cached; evaluating them must take microseconds. AWS has published on using automated reasoning (an SMT-solver-based tool called Zelkova) to answer questions such as "can anyone outside my account read this bucket?" over policies. See Authentication and Authorization.
Public access, the classic leak. Many real data breaches were simply buckets made publicly readable by mistake. The modern defence is layered: Block Public Access settings that override any policy or ACL granting public access, which AWS turned on by default for new buckets in April 2023, along with disabling ACLs by default for new buckets.
Encryption at rest. Three key-management options, each a different trust boundary:
- SSE-S3: the store manages keys. Since January 2023, S3 encrypts all new objects with this by default.
- SSE-KMS: keys live in a key management service the customer controls (rotate, audit, revoke access). The store uses envelope encryption: each object (or a group of objects) gets a data key, which encrypts the bytes; the data key is itself encrypted by the customer's master key in KMS and stored in the object's metadata. Reads ask KMS to decrypt the data key. To avoid a KMS call per object, S3 Bucket Keys derive per-bucket intermediate keys that are cached briefly.
- SSE-C: the customer sends the key with each request; the store uses it and discards it, keeping only a hash for validation. The store cannot read the data without the customer.
Client-side encryption (encrypt before upload) puts the store entirely outside the trust boundary. Encryption in transit is TLS between clients and front ends, and also between internal services. See Security Fundamentals for System Design.
Multi-tenancy and noisy neighbours. All customers share front ends, metadata partitions and disks. One customer's batch job must not ruin another's latency:
- Isolation in the metadata tier comes naturally from range partitioning: one bucket's hot prefix splits into its own partitions.
- Per-tenant quotas and fair queueing at front ends and data nodes, so a tenant at its limit gets 503s while others are unaffected.
- Shuffle sharding: assign each tenant a small random subset of front-end cells, so a tenant whose requests crash servers (a poison request) can only take down its own subset, and almost no other tenant shares the exact same subset. AWS has written about this technique in the Amazon Builders' Library.
- Data spread: a tenant's data is spread across all disks by placement, so no tenant can monopolise disk I/O on a few drives, and large stripes of any tenant are spread across many spindles.
Audit. Access logs and API audit trails (CloudTrail in AWS) record who did what, and are themselves stored as objects, often in a locked bucket.
Bottlenecks and Failure Modes#
| Failure / hotspot | Impact | Mitigation |
|---|---|---|
| Single disk failure (about 5 a day per region) | Fragments missing, stripes lose one unit of margin | Grace period, declustered repair across hundreds of partners, done within about an hour |
| Rack or power-domain loss | Thousands of disks at once, repair burst | Placement never puts two fragments of a stripe in one rack, prioritise most-endangered stripes, rate-limit repair |
| Whole availability zone outage | A third of capacity unreachable, repair storm risk | Codes tolerate one zone plus extra fragments, degraded reads, long grace before repairing a zone |
| Correlated drive batch or firmware bug | Many failures in a short window, beyond independent-failure math | Mix drive models and batches across groups, staged firmware rollout, watch AFR per batch |
| Latent sector errors and bit rot | Repair discovers a fragment already bad | Checksums on every read, scrubbing every few weeks, end-to-end audits |
| Hot prefix in the metadata index | 503 Slow Down, elevated latency for that bucket | Load-based partition splits, client backoff with jitter, documented per-prefix rates |
| Hot single object | One stripe and one metadata key overloaded | CDN, front-end metadata cache with sequence validation, extra replicas for hot stripes |
| Metadata partition leader failure | Writes to its key range pause | Raft election within seconds, short leases, clients retry |
| Front end crashes mid-PUT | Fragments written but never committed | Commit point in metadata, orphans reclaimed by mark and sweep after a safety delay |
| GC bug deletes live data | Permanent loss on every replica | Safety delays, soft delete with restore window, invariant checks, staged rollout of GC code |
| Repair or compaction starves customer traffic | Tail latency spikes | Separate I/O budgets, priority queues, throttles tied to foreground SLO |
| Noisy tenant or poison request | Other tenants slowed or front ends crash | Per-tenant quotas, fair queueing, shuffle sharding of front-end cells |
What Interviewers Expect#
Mid-level#
- Separates metadata (names, sizes, permissions, locations) from data (the bytes), and explains why.
- Puts the bytes on many storage nodes and keeps metadata in a sharded, replicated database.
- Replicates data three times across machines and explains that a write is not acknowledged until enough copies are durable.
- Describes the PUT and GET paths clearly, including what happens when one storage node is down.
- Knows multipart upload exists for large files and presigned URLs for direct client uploads.
- Gives reasonable capacity numbers: object count, total bytes, request rate.
Senior#
- Argues for erasure coding over replication with numbers (1.5x versus 3x storage) and explains its repair and small-object costs.
- Places fragments across failure domains (disk, server, rack, zone) and explains how the code survives a zone loss.
- Explains the commit point: data written first, metadata record makes the object visible, and how that enables atomic overwrite and safe failure handling.
- Designs listing with a range-partitioned index, explains hot prefixes and splitting, and explains 503 backoff.
- Covers garbage collection of orphans with a safety delay, and lifecycle rules.
- Explains strong read-after-write consistency and where staleness comes from (caches, followers).
Staff+#
- Derives durability from AFR, repair window and code parameters, and shows why repair speed matters as much as redundancy.
- Identifies correlated failures, latent errors, software bugs and operator error as the real risks, and designs defences for each.
- Discusses advanced codes (LRC, regenerating codes) and the repair-bandwidth trade-off.
- Designs failure detection with graded states, grace periods, prioritised repair and storm control.
- Discusses tail latency (reading extra fragments, hedging), noisy neighbours and shuffle sharding.
- Talks about how the system is changed safely: formal methods, staged deployment, invariant auditing, and how a 2020-style move from eventual to strong consistency could be done without downtime.
Deep Dive: durability numbers worked through with a Markov modelShow
The estimates in deep dive 5 can be made more precise with the standard Markov chain model of a redundancy group, used in storage reliability since the RAID papers of the late 1980s (Patterson, Gibson and Katz, "A Case for Redundant Arrays of Inexpensive Disks (RAID)", SIGMOD 1988).
Model. A group has n pieces and survives up to m losses (m = 2 for three replicas, m = 6 for RS(12, 6)). State i means i pieces are currently lost. From state i, the next failure happens at rate (n - i) x λ, where λ is the per-disk failure rate. Repair moves from state i back to i - 1 at rate μ = 1 / MTTR. State m + 1 is data loss and is absorbing.
Result. When repair is much faster than failure (μ much larger than nλ, true for any real system), the mean time to data loss is approximately:
MTTDL ≈ μ^m / ( n x (n - 1) x ... x (n - m) x λ^(m + 1) )
Intuition: to reach loss you need m + 1 failures, each successive one arriving before the repair of the previous state. Each step "costs" a factor of roughly (n - i)λ / μ, the chance that another piece fails before repair finishes.
Numbers. AFR = 1.5 percent gives λ = 0.015 / 8,760 h, about 1.71 x 10^-6 per hour. MTTR = 24 hours gives μ = 1/24 per hour.
| Scheme | n, m | MTTDL per group | Annual loss probability per group |
|---|---|---|---|
| 3 replicas, MTTR 24 h | 3, 2 | μ^2 / (6λ^3), about 6.6 x 10^9 years | about 1.5 x 10^-10 |
| 3 replicas, MTTR 1 h | 3, 2 | about 3.8 x 10^12 years | about 2.6 x 10^-13 |
| RS(12, 6), MTTR 24 h | 18, 6 | μ^6 / (18 x 17 x ... x 12 x λ^7), about 8.6 x 10^19 years | about 1.2 x 10^-20 |
The 3-replica, 24-hour row matches deep dive 5's back-of-the-envelope figure exactly. The RS row is about 700 times more pessimistic than deep dive 5's quick estimate because the Markov chain gives each successive failure a fresh repair window; neither model is "right" because both assume independence.
From per-group to fleet. If the store has G groups, expected losses per year are about G / MTTDL. With 10 trillion objects packed into, say, 100 billion stripes, RS(12, 6) at 1.2 x 10^-20 per stripe gives about 10^-9 stripe losses per year. Three replicas with a 24-hour repair would give about 15 stripe losses a year, each possibly containing many small objects. This is why packing small objects into stripes raises the stakes: a lost stripe loses everything in it.
Adding correlation. Suppose 1 in 1,000 disk failures is part of a correlated event that takes out an entire rack within minutes. With placement guaranteeing at most one fragment per rack, a rack event costs each affected stripe one fragment, which RS(12, 6) shrugs off. Without rack-aware placement, a rack event could take several fragments of one stripe at once, and the effective m collapses. The model teaches the lesson numerically: redundancy only counts if the pieces fail independently, and placement is what makes them independent.
Latent errors in the model. If a fraction ε of fragments are silently bad at any moment, each "available" piece is really available with probability 1 - ε. With scrubbing every 14 days and a latent error rate of, say, one bad fragment per 10^5 per scrub cycle, ε is about 10^-5, small enough not to change the RS result, but for three replicas a latent error effectively turns the second failure into data loss. Scrubbing frequency enters the durability math just as MTTR does.
Deep Dive: Reed-Solomon by hand, a toy exampleShow
Reed-Solomon codes rest on one fact: a polynomial of degree k - 1 is fully determined by any k of its points. A line (degree 1) is fixed by any 2 points; a parabola (degree 2) by any 3.
Encoding k = 3 data values with m = 2 parity values. Data: 2, 3, 6. Treat them as the values of a polynomial at x = 1, 2, 3. The unique parabola through (1, 2), (2, 3), (3, 6) is f(x) = x^2 - 2x + 3. Check: f(1) = 1 - 2 + 3 = 2, f(2) = 4 - 4 + 3 = 3, f(3) = 9 - 6 + 3 = 6. The parity values are the same polynomial evaluated at new points: f(4) = 11, f(5) = 18. Store the five fragments 2, 3, 6, 11, 18 on five different disks. Because the first three are the original data, the code is systematic: normal reads just fetch them.
Decoding after losing two fragments. Suppose the disks holding f(1) and f(3) die. We still have (2, 3), (4, 11), (5, 18). Fit f(x) = ax^2 + bx + c:
- 4a + 2b + c = 3
- 16a + 4b + c = 11
- 25a + 5b + c = 18
Subtracting gives 12a + 2b = 8 and 9a + b = 7, so a = 1, b = -2, c = 3. The polynomial is back, and f(1) = 2, f(3) = 6 are recovered. Any 3 of the 5 fragments would have worked.
Why finite fields. Over ordinary integers, parity values grow (11 and 18 do not fit the original range), and division produces fractions. Real codes do the same algebra in a finite field, usually GF(2^8), whose 256 elements are exactly the byte values. Addition there is XOR, multiplication uses lookup tables, every non-zero element has an inverse, and every result is again one byte. So a parity fragment is exactly the size of a data fragment, and encoding processes data byte by byte across the stripe. Libraries such as Intel ISA-L use SIMD instructions to encode at several GB/s per core.
The m = 1 special case is XOR. With one parity fragment, RS reduces to RAID-5-style parity:
// One parity fragment: p = d0 XOR d1 XOR ... XOR d(k-1), byte by byte.
function encodeParity(data: Uint8Array[]): Uint8Array {
const p = new Uint8Array(data[0].length);
for (const d of data) for (let i = 0; i < p.length; i++) p[i] ^= d[i];
return p;
}
// Rebuild any single missing fragment by XOR-ing all survivors (including p).
function rebuild(survivors: Uint8Array[]): Uint8Array {
return encodeParity(survivors);
}What decoding costs. Rebuilding one lost fragment needs k survivors, whichever code you choose among RS codes. That k-times read amplification on repair is the motivation for locally repairable codes (deep dive 4), which add local parities so that a single loss is rebuilt from a small local group, and for regenerating codes (Dimakis and colleagues, 2010), which reduce the bytes each survivor must send.
Deep Dive: how real object stores and blob systems are builtShow
These systems are where the ideas on this page come from. Details below are from published papers and public talks; internals that were never published are not described.
- Amazon S3 launched in March 2006 with a simple PUT, GET, DELETE and LIST interface. Its public milestones match this page's deep dives: strong read-after-write consistency for all operations in December 2020; default encryption of new objects in January 2023; Block Public Access and disabled ACLs by default for new buckets in April 2023; Express One Zone, a single-zone, low-latency class with directory buckets, in late 2023; and conditional writes in 2024. Its storage node software, ShardStore, is a log-structured key-value store written in Rust; the paper "Using Lightweight Formal Methods to Validate a Key-Value Storage Node in Amazon S3" (Bornholt and colleagues, SOSP 2021) describes how executable reference models and property-based testing are used to check it for crash consistency and correctness. AWS has stated in talks that S3 holds hundreds of trillions of objects and handles well over 100 million requests per second at peak.
- Google File System (Ghemawat, Gobioff and Leung, SOSP 2003) used a single master for metadata, 64 MB chunks replicated three times on chunkservers, and clients that talked to chunkservers directly for data. It is the clearest example of the "Good" design in the high-level section, and its single master became the scaling limit. Its successor, Colossus, distributes metadata (Google has said it stores file system metadata in Bigtable) and uses erasure coding widely.
- Windows Azure Storage (Calder and colleagues, SOSP 2011) has three layers: front ends, a partition layer that range-partitions objects by name and serves them with consistent semantics, and a stream layer that stores append-only "extents" replicated three times. Once an extent is sealed (no more appends), it can be erasure-coded in the background, the "replicate then encode" pattern. Azure later adopted Local Reconstruction Codes (Huang and colleagues, ATC 2012) to cut repair cost.
- Facebook Haystack (Beaver and colleagues, OSDI 2010) stored billions of photos by packing many photos into large volume files and keeping each photo's offset in memory, so a read needs one disk seek. f4 (Muralidhar and colleagues, OSDI 2014) moved "warm" blobs to RS(10, 4) within a region plus an XOR of two regions' data in a third, reaching an effective replication factor of 2.1 instead of 3.6. Tectonic (Pan and colleagues, FAST 2021) later consolidated many storage systems into one exabyte-scale, multitenant file system with metadata layered on a sharded key-value store.
- Ceph (Weil and colleagues, OSDI 2006) avoids a central placement table: its CRUSH algorithm (Weil and colleagues, SC 2006) computes placement from a cluster map and placement rules, so any client can find data. Its RADOS Gateway exposes an S3-compatible API, which makes Ceph a common choice for self-hosted object storage.
- MinIO is an open-source S3-compatible store that erasure-codes each object across a set of drives and keeps object metadata alongside the data on those drives, rather than in a separate metadata database. That keeps it simple to deploy, at the cost of making listing and metadata-heavy workloads depend on the drives.
- Backblaze has publicly described splitting each file into 17 data and 3 parity shards across 20 storage servers in a "vault", and publishes quarterly hard-drive failure statistics that are one of the best public sources of real AFR data (typically between about 1 and 2 percent per year across its fleet, varying by model).
- HDFS added erasure coding in Hadoop 3, with RS(6, 3) as a common policy, alongside its traditional three-way replication.
Common threads: every one separates metadata from data; every large one moved from replication to erasure coding for most bytes; every one packs small objects into larger units; and the newest put heavy effort into validation (formal methods, testing, auditing), because at this scale bugs are the main threat to durability.
Deep Dive: failure walkthroughs, minute by minuteShow
1. An availability zone loses power. Placement uses RS(12, 6) with six fragments per zone across three zones.
- Second 0 to 10: heartbeats from one zone's data nodes stop. Front ends see connection errors to those nodes.
- Reads: every stripe still has 12 fragments in the other two zones, exactly k. GETs switch to degraded mode, reading whichever 12 remain and decoding; latency rises because there is no spare fragment to hedge with.
- Writes: new PUTs cannot place six fragments in the dead zone. The system either writes stripes with all 18 fragments in two zones (nine and nine, which survives six disk or rack failures but not the loss of a second zone, and is re-placed once the zone returns) or writes 3-way replicas temporarily and re-encodes later. Which one a real system picks is a policy choice; both keep acknowledged writes safe.
- Metadata: Raft groups with one of three replicas in the dead zone keep a majority and continue. Groups whose leader was there elect a new leader within seconds.
- Repair: the cluster manager recognises a correlated zone event and does not start repairing petabytes immediately. Zone outages almost always end within hours, and rebuilding a third of the region would take days and saturate the network.
- Recovery: power returns, nodes rejoin, and only writes that landed elsewhere during the outage need rebalancing.
2. A batch of drives starts failing. Monitoring shows the AFR of one drive model and manufacturing batch climbing from 1.5 percent to 8 percent.
- Each failure is repaired normally, but the scheduler's priority queues show more stripes than usual missing two fragments.
- Because placement mixes models and batches, no stripe has more than one or two fragments on the bad batch, so margins hold.
- Operators proactively drain the remaining drives of that batch: data is copied off before they fail, at a controlled rate, turning an emergency into a planned migration.
3. A bad deploy in the storage node software. A new build has a bug that writes corrupt checksums on 0.1 percent of new fragments.
- The deploy is staged: one zone at a time, a small percentage of nodes, with bake time. Read-path checksum failures on new fragments alert within minutes on the first wave.
- The deploy is rolled back. Fragments written by the bad build are located from their writer version, verified, and rebuilt from the other fragments of each stripe, which were written by healthy nodes.
- Because a stripe's 18 fragments land on 18 different nodes, only a few of which ran the new build, almost every stripe is repairable. This is why deploys are staged by failure domain: never upgrade more nodes of one stripe at once than the code can lose.
4. Silent bit rot. A scrubber finds a fragment whose checksum no longer matches. It is re-read (to rule out a transient error), then marked bad, and repair rebuilds it from 12 others. The disk's error count goes up; past a threshold, the disk is drained and retired before it fails outright.
5. A metadata partition gets hot. A customer starts a job writing 20,000 objects a second under one new prefix. The partition exceeds its load threshold, the front ends start returning 503 Slow Down for a fraction of requests, the partition splits (twice, within a minute or two), and the new partitions move to separate nodes. The client's SDK retries with backoff, and its throughput settles at the new, higher level.
Deep Dive: multi-region and cross-region replicationShow
A region already survives the loss of a zone. Some customers also need copies in other regions: for disaster recovery against a whole-region event, for compliance (a copy in a different jurisdiction or account), or for lower latency to users on another continent.
Asynchronous replication. Cross-region replication (CRR) is configured per bucket with rules (prefix or tag filters, destination bucket, destination storage class). When an object version is committed in the source region, a change event is recorded, and a replication service reads the object and PUTs it into the destination bucket, preserving the version id and metadata. Replication is asynchronous: most objects arrive within seconds to minutes, and S3 offers a Replication Time Control option backed by an SLA that 99.99 percent of objects replicate within 15 minutes. That means the recovery point objective is minutes, not zero.
Why not synchronous? Writing to two regions before acknowledging adds cross-region round trips (tens to over a hundred milliseconds) to every PUT and makes writes unavailable when either region or the link is unhealthy. For blob storage, asynchronous replication with a measured lag is nearly always the right trade-off; see Multi-Region and Global Data and Disaster Recovery and Backups.
Semantics to decide.
- Deletes: whether delete markers replicate is configurable, and permanent version deletes are deliberately not replicated, so a malicious or mistaken delete in one region cannot destroy the other copy.
- Loops: with two-way replication, each replicated write is tagged as a replica, so it is not replicated back.
- Ordering: versions of the same key can arrive out of order; because version ids carry the source order, the destination still knows which is current.
- Existing objects: rules apply to new writes; backfilling an existing bucket is a separate batch job.
- Encryption: objects encrypted with customer KMS keys need a key in the destination region and permission to use it.
Active-active reads can be built on top: multi-region access points route a request to the nearest healthy region holding a copy. Writes in two regions to the same key are then resolved by last-writer-wins on replication, so applications that write from several regions must partition keys by region or accept that outcome.
Deep Dive: observability for an object storeShow
What to measure and alert on (see Observability: Logs, Metrics and Traces):
- Durability health: number of stripes at each remaining margin (how many have lost 1, 2, 3 fragments), repair queue depth and age per priority, time to repair a lost disk. The alert that matters most: any stripe within one or two fragments of loss.
- Hardware: AFR by drive model and batch, SMART warnings, latent error rate found by scrubbing, scrub cycle completion (has every fragment been verified in the last N weeks?).
- Request path: request rate, error rate (4xx versus 5xx separately; 503 Slow Down separately again), p50, p99 and p99.9 latency per operation and per object-size band, time to first byte for GETs.
- Metadata tier: per-partition load, split rate, leader elections, Raft replication lag, hottest prefixes.
- Background work: GC reclaimed bytes versus garbage created, compaction write amplification, lifecycle backlog, replication lag for CRR.
- Capacity: free space per zone and per failure domain, projected exhaustion date with procurement lead time (drives and servers take months to arrive and rack).
- Correctness: results of end-to-end audits and invariant checks. Zero tolerance: any mismatch is investigated as a potential durability event.
A useful habit: treat durability like availability, with an explicit budget, dashboards and post-incident reviews for every event that reduced margin, even when nothing was lost.
Deep Dive: a 45-minute interview plan and common variantsShow
Plan.
- Minutes 0 to 5: clarify. Object sizes, request mix, durability target, consistency, listing, versioning, multi-region. State the API (PUT, GET, DELETE, LIST, multipart).
- Minutes 5 to 10: estimate. Total bytes, objects, request rate, disks needed with your chosen redundancy, daily failures and repair bandwidth.
- Minutes 10 to 20: high-level design. Front ends, metadata tier (range-partitioned, replicated), data tier (storage nodes), placement service, background services. Walk PUT and GET, and name the commit point.
- Minutes 20 to 35: deep dives the interviewer cares about. Usually two or three of: erasure coding and durability math, placement across failure domains, metadata scaling and listing, consistency, multipart, GC.
- Minutes 35 to 45: failures and operations. Zone loss, repair storms, hot prefixes, bugs, security. Finish with trade-offs you made.
Variants and how the design shifts.
- "Design Dropbox or Google Drive." A sync product built on top of an object store: chunking, deduplication, a metadata journal and notifications. The object store is one box in that design.
- "Design a photo store like Haystack." Mostly small immutable objects with a heavy read skew: emphasise packing into volumes, an in-memory index for one-seek reads, and a CDN in front.
- "Design a backup or archive service." Write-once, rarely read: wide codes, cheap dense media, batched restores, Object Lock, very long retention.
- "Design HDFS or a distributed file system." Adds directories, renames, appends and POSIX-like semantics, so the metadata tier needs hierarchical namespace operations and stronger coordination.
- "Design a key-value store." Small values, low latency, frequent updates: replication and consistent hashing dominate, erasure coding usually does not fit.
- "Design a CDN." Caching and geography, with the object store as the origin.
Key Takeaways#
- Split metadata from data. A range-partitioned, replicated metadata index holds names, versions, permissions and chunk locations; storage nodes hold immutable fragments. The metadata write is the commit point: data first, then one atomic record makes the object visible. See Object Storage and Blob Storage.
- Erasure coding beats replication for bytes at rest. RS or LRC codes give zone-level fault tolerance at about 1.5 to 1.8 times overhead instead of 3 times, at the cost of repair read amplification and poor fit for tiny objects, which are packed into larger stripes or replicated.
- Durability is redundancy times repair speed times independence. The repair window enters the math to the power of the code's margin, so declustered, prioritised repair matters as much as extra parity. Placement across disks, racks and zones is what makes failures independent.
- The real threats are correlated. Drive batches, zones, latent errors, software bugs and operators lose more data than independent disk failures. Scrubbing, audits, staged deploys by failure domain, safety delays and formal methods are durability features.
- Strong consistency lives in the metadata tier. Per-key ordering by a partition leader, caches validated by sequence numbers, and conditional writes for compare-and-set. Immutable fragments need no consistency protocol. See Consistency Models and Database Replication.
- Listing and hot spots come from range partitioning. Load-based splits, 503 backoff, caches and a CDN handle skew. See Partitioning and Sharding and Content Delivery Networks (CDN).
- Large objects use multipart upload, where completion is a metadata-only stitch of parts, and parallel ranged GETs. See Pattern: Handling Large Files and Blobs.
- Background work is a first-class workload. Repair, scrubbing, garbage collection with mark and sweep plus safety delays, compaction, lifecycle and replication each need their own capacity budget and throttles. See Data Lifecycle, Tiering and Retention.
- Security is per request. Signed requests, explicit-deny-wins policies, public-access blocks on by default, envelope encryption with customer-controlled keys, and per-tenant isolation through quotas and shuffle sharding. See Security Fundamentals for System Design.