Design a Blob Store like S3
Understanding the Problem
🪣 What is a blob store? A blob store (or object store) keeps arbitrary files, called objects, under a bucket and a key, and serves them over HTTP. Objects are written whole and read whole or by byte range; there's no editing in the middle and no directory tree, just keys that may contain slashes. Amazon S3 is the reference, with Google Cloud Storage, Azure Blob Storage and open-source MinIO and Ceph close behind.
"Design S3," "design an object store" and "design a file storage service for images and videos" all lead here. The interesting parts are the same: how you separate the small, transactional metadata from the huge, immutable data, how you reach very high durability without paying for many full copies, and how clients move large files in and out efficiently.
Functional Requirements
Core Requirements
- Users should be able to upload an object to a bucket under a key, and download it again, whole or by byte range.
- Users should be able to upload very large objects (up to 5 TB) in parts, in parallel, and resume after failures.
- Users should be able to list the objects in a bucket by key prefix, and delete objects.
- Users should be able to give someone else time-limited access to upload or download one object, without sharing credentials.
Below the line (out of scope)
- Object versioning, lifecycle rules (move to cold storage after 30 days) and cross-region replication. We'll mention where they'd plug in.
- Searching inside objects, or by arbitrary metadata.
- Billing and the IAM policy language.
Non-Functional Requirements
Core Requirements
- The system should store 100 PB across 100 billion objects (1 MB average), with object sizes from 0 bytes to 5 TB.
- The system should be extremely durable: 99.999999999% (eleven nines) per object per year, and survive the loss of a whole availability zone.
- The system should be highly available for reads and writes (99.99%).
- The system should handle 100k PUTs/sec and 1M GETs/sec, with time to first byte under 100 ms for small objects, and scale aggregate bandwidth into the terabits per second.
- The system should be strongly consistent: once a PUT returns, any GET or LIST sees the new object.
Below the line (out of scope)
- Sub-millisecond latency. Object stores trade latency for cost and durability.
- Atomic operations across multiple objects.
The math shapes the design in three ways.
Raw capacity. Storing 100 PB with three full copies is 300 PB. On 20 TB hard drives, that's about 15,000 drives. With erasure coding at 1.5x overhead (deep dive 1), it's 150 PB, or about 7,500 drives. Halving the drive count is the single biggest cost lever in the whole system.
Failures. Hard drives fail at an annual rate on the order of 1-2%. With 7,500-15,000 drives, that's a few drive failures every week, every week, forever. Rebuilding a 20 TB drive from a single source at about 200 MB/s takes more than a day. Durability depends on rebuilding much faster than that, which means spreading the work across many drives.
Metadata. 100 billion objects at a few hundred bytes of metadata each is tens of terabytes of metadata, with 1.1M operations a second against it. That's a large distributed database on its own.
The key insight: a blob store is two systems. The data layer stores huge amounts of immutable bytes and cares about cost and durability. The metadata layer stores small records and cares about consistency and fast lookups. Designing them separately is what makes the problem tractable.