Library
35 min read

Design object storage

Object storage is where the internet keeps its files: photos, videos, backups, the raw pages a crawler downloads. You hand it a name and some bytes, and later you ask for the bytes back by that name. Amazon S3 is the famous one.

Amazon publishes a durability figure for S3 of eleven nines, 99.999999999%. In plain words: if you store ten million objects, you should expect to lose one of them roughly once every ten thousand years. Watch one photo get stored, and then watch the machinery that keeps that promise.

ClientLoad balancerRequest routersMetadata servicePrefix indexErasure coderPlacementStorage nodesRepair serviceScrubber

Send. A client sends a PUT for photos/2026/08/25/img_88.jpg: the name, and the bytes of the photo.

Disks do not have eleven nines. A typical hard drive has something like a 1 to 2 percent chance of dying in any given year. That sounds small until you own a hundred thousand of them: 1 to 2 percent of 100,000 is 1,000 to 2,000 dead drives a year, several every single day. The whole design is the machinery that turns that hardware into the published number, and the interesting question is not how to store bytes. It is how to make a promise like that and defend it with arithmetic.

A few words first, because the whole page uses them:

  • An object is one stored file plus a little information about it, like its size and a hash of its contents.
  • A bucket is a named container of objects, and a key is an object's full name inside it, like 2026/08/25/img_88.jpg. The slashes are just characters. There are no real folders.
  • Durability is the chance your data still exists. Availability is the chance you can reach it right now. A system that is down for an hour but loses nothing had bad availability and perfect durability.
  • Metadata is the data about the data: for each object, which machines hold its pieces.

Step 1: Understand the problem#

The number the interviewer cares about is durability, and it is the one candidates skip past fastest. Pin it down first, because it pays for everything else.

You askThey sayWhat it settles
How durable, and how available? They are different numbers.Eleven nines of durability. Four nines of availability.Everything. Losing data is unacceptable, being briefly unreachable is survivable, so the design spends heavily on spare copies and cheaply on uptime.
How big are objects, and how many?A few kilobytes to terabytes, and trillions of them.Two separate problems. Storing the bytes is easy to spread across machines. The trillion small metadata rows are a harder database problem than the storage is.
Can an object be changed in place?No. Overwrite the whole thing or nothing.Objects are immutable (never edited after writing). That makes a copy just a copy, makes caching safe, and removes every half-written-update problem you would otherwise design around.
What do reads need to see after a write?Read after write for new objects.Once a PUT succeeds, the next GET must find it. That fixes the order of the write path: metadata is committed before the write is acknowledged.
Do users list objects by prefix?Constantly. It is how everyone uses it.Metadata has to be kept in key order, not scattered by a hash of the key, and that is what makes the metadata tier hard to split across machines.
One region or many?Durability inside one region, optional copying to other regions.Cross region copying is a separate, after-the-fact pipeline. Making every PUT durable in two regions before answering would put an ocean in your write latency.

That fourth answer, "read after write", means any client that reads after a successful PUT sees the new object, never a stale "not found". If the difference between seeing the latest write and catching up later is new, strong vs eventual consistency explains it.

What you are building#

Functional requirements
What the system does.
  • PUT, GET and DELETE of immutable objects by key. Objects are replaced whole, never edited in place.
  • Objects from a kilobyte to several terabytes. That range is five orders of magnitude, and it forces two different code paths.
  • Extreme durability, with the arithmetic to back the claim. This is the product. Availability comes second to not losing data.
  • Flat key namespace with prefix listing. There are no directories, and pretending otherwise causes the classic hot partition.
Non-functional requirements
How well it has to do it. The numbers you commit to.
  • Trillions of objects, exabytes in total.
  • Durability target of eleven nines, defensible with arithmetic.
  • Read after write for new objects.
  • A whole datacentre can fail without data loss.
Out of scope
What you cut, and say so out loud.
  • A normal filesystem interface. Writing into the middle of an object changes everything, which is why this is object storage and not a filesystem.
  • Access control and encryption, which are real and large but can be designed separately.
  • Moving old objects to cheaper cold storage, which is a scheduling problem on top of this.

Replication or erasure coding#

This is the decision the whole system turns on. Start with the obvious answers and see where each one breaks.

How do you keep a file safe when disks keep dying?

  1. First try
    One copy on a good disk
    Write the object to one disk and trust it.
    Where it breaks: With a 1 to 2 percent yearly failure rate per disk, a fleet of 100,000 disks loses several every day, and every object on them is simply gone.
  2. Better
    Three full copies on three machines
    Write the whole object three times. A read can use any copy, and losing two copies is still fine.
    Where it breaks: It costs 3 GB of disk for every 1 GB stored. At exabyte scale that bill is the business, and it still survives only two failures.
  3. What you ship
    Erasure coding for big objects, copies for small ones
    Cut the object into 6 data fragments, compute 3 parity fragments, and put all 9 on different machines. Any 6 rebuild it, so it survives 3 failures while storing 1.5 GB per 1 GB. Tiny objects still get 3 copies, because cutting a 4KB object into nine pieces costs more than it saves.

Parity is the trick that makes the third rung work, and the smallest version fits in your head. Take two data fragments, A = 5 and B = 3, written in bits as 0101 and 0011. Store a third fragment P = A XOR B (XOR sets a bit to 1 where the two inputs differ), which is 0110, or 6. Now lose B. XOR the survivors, A and P: 0101 XOR 0110 = 0011, which is 3, and B is back. That is one parity fragment covering one loss. The codes real systems use extend the same idea so that 3 parity fragments can stand in for any 3 lost fragments out of 9.

Here are the two schemes side by side, for a 1 GB object.

Durability scheme
Three complete copies. Simple, and a read is a read from any one of them, so reads are cheap and a read with a copy missing costs nothing extra. It survives two failures and costs 3 GB to store 1 GB. For small objects this is the right answer, because the fixed cost of splitting a 4KB object into fragments is worse than just copying it.

Erasure coding wins on the two numbers people care about: three failures survived instead of two, at half the storage. What it costs is read complexity and repair traffic. Rebuilding one lost fragment means reading six others, so recovering a failed disk moves several times more data across the network than copying a replica would.

Try it. Knock fragments out one at a time, then switch the placement and cut the power to one rack.

One object, 6 data + 3 parity fragments
Readable, 9 of 9 left
All nine fragments are healthy. Click a fragment to lose it, or cut the power to rack 1.
Placement: one fragment per rack. Rack 1 holds 1 of the 9 fragments, so a power cut there loses 1. Three full copies of the same object would take 3x the space and survive only 2 losses; these nine take 1.5x and survive 3.

The fragments did not change between the two placements. Only where they sat did. That is why placement, the box that picks racks, gets a whole step on the write path.

Back of the envelope#

The eleven nines promise can be checked with a short calculation. An object is lost only if more than 3 of its 9 fragments die before repair puts them back. So the chance of loss depends on how often disks die, and on how long a lost fragment stays lost. Nines here mean the same as in availability and the nines, just counted for losing data rather than being down. If this kind of estimate is new, the back of the envelope chapter walks through the method.

Durability arithmetic
6
3
2%
1
Fragments per object6 data + 3 parity = 9
Storage overhead9 / 6 = 1.50x
Failures survived3
Chance of loss per object per year4.1e-13
12 nines
at 1.50x storage, if a lost fragment is rebuilt within 1 day

Now drag the repair slider. Durability depends on fixing a lost fragment before enough others fail to cross the line, so the same code that rebuilds in a day is far more durable than one that takes two weeks. That is why placement spreads fragments widely: many machines then share the rebuild work and it finishes faster.

Drag the parity slider and the nines move. Then drag the repair slider and watch them move just as much. The durability claim is not only a property of the coding scheme. It is a property of how fast you repair, which is the same lesson as "how long it takes to recover matters as much as how often you fail" in the availability chapter.

Correlated failure is what actually loses data

All the arithmetic above assumes disks fail independently, one at a time and by chance. They do not. A rack loses power, a batch of drives from one manufacturing run fails the same month, a firmware bug hits every drive of a model at once, or a bad deploy corrupts fragments faster than repair can fix them. Placement is what turns the theoretical number into a real one: spread fragments across racks, power domains and availability zones, so no single shared event can take more than the parity count. You just watched this happen in the widget above.