Full answer
Requirements
Functional:
- Create buckets; PUT, GET, DELETE and LIST objects by key; objects from bytes to terabytes.
- Multipart upload for large objects; versioning; pre-signed URLs.
Non-functional:
- Durability of many nines: data must survive disk, machine and rack failures.
- High availability for reads and writes; strong read-after-write consistency for new objects.
- Throughput scales with the number of clients.
Capacity estimates
Assumptions: 100 PB of logical data, 100B objects (1 MB average), about 500 bytes of metadata per object, erasure coding with 6 data and 3 parity fragments.
- Raw storage with erasure coding: 100 PB x 9 / 6 = 150 PB.
- Raw storage with 3 replicas: 300 PB. Erasure coding saves 150 PB.
- Metadata: 100B x 500 bytes = 50 TB, which needs its own sharded, replicated store.
API
PUT /{bucket}/{key} body: bytes -> 200 ETag: "9f86d0..."
GET /{bucket}/{key} Range: bytes=0-1048575
DELETE /{bucket}/{key}
GET /{bucket}?list-type=2&prefix=photos/2026/&continuation-token=..
POST /{bucket}/{key}?uploads -> upload_id; then PUT parts; then POST ...?uploadId=.. to complete
Data model
- Metadata (sharded by hash of bucket and key, with a secondary ordering for prefix listing): bucket, key, version_id, size, etag, created_at, storage_class, list of chunk IDs.
- Chunk placement: chunk_id to the 9 fragment locations (node, disk).
- Data nodes: fragments in large append-only files, with checksums per block.
High-level design
mermaid
flowchart LR
C[Client] --> FE[Front-end API servers]
FE --> MS[(Metadata service)]
FE --> PL[Placement service]
FE --> DN1[Data node rack 1]
FE --> DN2[Data node rack 2]
FE --> DN3[Data node rack 3]
SCR[Scrubber and repair] --> DN1
SCR --> MS
GC[Garbage collector] --> DN2Write and read paths
- Write. The front end splits the object into chunks (for example 64 MB), encodes each into 6 data and 3 parity fragments, and writes the 9 fragments to 9 different nodes in different racks or zones. When enough fragments are durable, it writes the metadata record last. Writing metadata last means a failed upload leaves only orphan fragments, which garbage collection removes, and never a visible half-written object.
- Read. Look up metadata, then read the 6 data fragments directly. If some are missing or slow, read parity fragments and decode.
- Small objects are packed together into larger files so the system does not manage billions of tiny files on disks.
Bottlenecks and trade-offs
- Erasure coding versus replication. Coding uses half the space of three copies but costs CPU, and repairing one lost fragment requires reading 6 others. Hot small objects can stay replicated for faster reads.
- Metadata scale (50 TB, very high request rates) is often the real bottleneck, especially for LIST with prefixes; shard carefully and avoid hot prefixes.
- Durability depends on detecting failures fast: scrubbers re-read checksums and repair before a second and third fragment are lost.
- Consistency. Making the metadata write the commit point gives read-after-write consistency for new objects.
- Deletes remove metadata first; space is reclaimed later by garbage collection, which also handles orphan fragments.
By level
Fresher: Explain that file details go in a metadata store and file contents are split and spread over many disks. A fresher should know why copies or parity pieces are needed.
Mid: Design chunking, erasure coding with placement across racks, and metadata-last writes. Do the storage math versus replication.
Senior: Discuss repair bandwidth, scrubbing, small object packing, metadata sharding and LIST, consistency guarantees and garbage collection. Expect durability reasoning tied to failure detection speed.
Key points
- Separate metadata service from data nodes
- Erasure coding 6 + 3 survives 3 lost fragments at 1.5x storage
- Spread fragments across racks or zones
- Write metadata last as the commit point
- Scrubbing and repair keep durability high
Common mistakes
- Storing objects only as three replicas at 100 PB scale without discussing cost
- Putting fragments of one chunk on the same rack
- Writing metadata before data is durable
- Ignoring the metadata store as a scaling problem
Follow-ups
- How would you implement versioning?
- How do you list a prefix with billions of keys quickly?
- How would you calculate durability from disk failure rates?
Tips
- Do the erasure coding storage math
- Explain metadata-last writes
- Mention scrubbing and failure domains
Evaluation rubric
- Clear metadata and data separation
- Correct erasure coding reasoning and math
- Write and read paths with consistency
- Durability, repair and metadata scaling