Design a Blob Storage Service with Buckets and Keys
System DesignModel answerLast updated
Design a scalable service where clients store, retrieve, list, and delete binary objects addressed by key inside named buckets.
The Problem
You are asked to design a general-purpose blob storage service. Clients organize their data into named buckets. Within a bucket, each object is an opaque sequence of bytes stored under a string key. Along with the raw bytes, the service tracks a small amount of metadata per object: its size, content type, and a checksum.
The prompt is intentionally open-ended. Before drawing any boxes, you should drive a scoping conversation to pin down the requirements.
Scope the Design First
Work through clarifying questions before proposing anything:
- Object size distribution — are objects mostly small (thumbnails, config files), mostly large (video, backups), or a wide mix? Is there a hard upper bound on object size?
- Scale targets — what total data volume should the system hold? What peak read and write rates (requests/sec and bytes/sec)? Single region or multi-region?
- Durability and availability — what are the SLA targets? (e.g., eleven nines of durability, 99.9% monthly availability)
- Consistency model — after a successful write, must a subsequent read from any node return the new object? Must a newly written object appear in list results immediately?
- Feature scope — is overwriting an existing key allowed? Do you need versioning, byte-range reads, multipart upload for large objects, and/or access control?
Your answer will be evaluated on the quality of your scoping, the clarity of your architecture, and your ability to discuss trade-offs — not on hitting a specific "correct" design.
What You Are Expected to Cover
- A minimal but complete client-facing API with the semantics of each operation
- How the system separates metadata management from raw data storage
- How data is placed and protected against hardware failure
- The write path end-to-end, including when an object becomes visible to readers
- The read path, including range reads and large objects
- How multipart uploads work and how very small objects are handled efficiently
- Background operations: failure detection, repair, and garbage collection
- A rough capacity estimate anchored to the numbers you agreed on in scoping
Hints
Hint 1
Start by splitting the system into two distinct layers: one that maps bucket+key to a physical location (metadata), and one that actually holds the bytes (data nodes). Each layer scales and fails independently.
Hint 2
Think about what 'durable' means in terms of hardware failures. If you replicate, how many copies and across which failure domains? If you use erasure coding instead, what do you gain and give up compared to replication?
Hint 3
A write is not a single atomic step — consider what sequence of operations happens between the client sending bytes and the service returning 200 OK, and at which exact point the object becomes readable by other clients.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Scoping Assumptions
Before designing anything, establish numbers. A reasonable baseline for a mid-scale service:
- Object sizes range from a few KB to several GB; a hard cap of 5 TB per object with multipart upload required above 100 MB.
- Target: 1 EB total capacity, 100k read requests/sec, 10k write requests/sec, single primary region with an async replica region.
- Durability target: 11 nines (comparable to S3). Availability: 99.9% monthly.
- Strong read-after-write consistency: a GET immediately following a successful PUT must return the new object. List results must also reflect a completed PUT.
- Features in scope: overwrite (no versioning initially), byte-range reads, multipart upload, bucket-level access control.
API
PUT /buckets/{bucket} # create bucket
DELETE /buckets/{bucket} # delete bucket (must be empty)
PUT /buckets/{bucket}/objects/{key} # upload object (full or initiate multipart)
GET /buckets/{bucket}/objects/{key} # download object (supports Range header)
HEAD /buckets/{bucket}/objects/{key} # metadata only
DELETE /buckets/{bucket}/objects/{key} # delete object
GET /buckets/{bucket}/objects?prefix=&after= # paginated prefix listing
Each PUT response includes an ETag (checksum) the client can use for conditional requests. Multipart upload is a three-step flow: initiate → upload parts → complete (which atomically assembles the parts).
Architecture: Two Layers
Metadata service maps (bucket, key) → object record (location of data chunks, size, checksum, content-type, creation time). This is a strongly consistent, low-latency store — a distributed key-value system like a Paxos/Raft-replicated store or a sharded relational database with a lookup index. Sharding by a hash of bucket+key distributes hotspots. This layer is small relative to total data volume; at 1 KB per metadata record and 100 billion objects, that is only ~100 TB, very manageable.
Data nodes hold the actual bytes. Each node is a simple append-only store that exposes write(chunk_id, bytes) and read(chunk_id, offset, length). The service layer sits in front of both: it accepts client requests, writes data to nodes, then commits the metadata record.
Durability: Replication vs. Erasure Coding
Replication (3 copies across 3 fault domains) is simple to implement and gives fast reads — any replica can serve. The cost is 3× storage amplification.
Erasure coding (e.g., Reed-Solomon 8+4: 8 data shards + 4 parity shards across 12 nodes) gives 11-nines durability with only 1.5× storage overhead, at the cost of reconstruction reads (need to fetch from multiple nodes) and more CPU for encoding/decoding.
A practical split: use 3-way replication for objects smaller than ~1 MB (latency-sensitive, lots of random access) and erasure coding for large objects (where the storage savings are significant). All chunks are checksummed at rest; nodes verify checksums on every read.
Write Path
- Client sends PUT to the frontend (stateless, load-balanced).
- Frontend assigns a new
object_id, splits data into chunks if large, and writes each chunk to the required number of data nodes (3 replicas or EC shards), in parallel where possible. - Once the required minimum acknowledgments arrive (all 3 replicas, or all 12 EC shards), the frontend atomically writes the metadata record pointing to those chunks.
- The metadata write uses compare-and-set to handle concurrent overwrites of the same key — last writer wins, with the previous version's chunks marked for garbage collection.
- Only after the metadata commit does the service return 200 to the client. This is the point at which the object is visible to all readers: strong read-after-write consistency is achieved because subsequent reads must go through the metadata service to locate chunks.
Read Path
GET resolves (bucket, key) in the metadata service to get chunk locations, then fetches bytes from a healthy replica or reconstructs from EC shards. Range reads are served by mapping the byte range to specific chunks and fetching only those, avoiding full-object reads for large files.
For very hot objects, a small read-through cache (by ETag) at the frontend layer reduces metadata and data node load.
Large Objects and Tiny Objects
Multipart upload: the client initiates an upload session, uploads parts (minimum 5 MB each) independently (parallelizable), then calls complete. The service assembles a logical object from the part records without copying bytes. If the session is never completed, a background job cleans it up after a configurable TTL.
Tiny objects: storing a 1 KB blob across 3 separate data nodes wastes iops and metadata overhead. A common optimization is to pack many small objects into a larger container file on each data node and index them by offset within the container (similar to Facebook's Haystack pattern).
Background Operations
Failure detection: data nodes send heartbeats to a health monitor. A node that misses heartbeats is flagged; the repair service identifies under-replicated chunks by scanning metadata records with missing replicas and re-replicates from surviving copies.
Repair: for EC-coded objects, reconstruction from surviving shards is sufficient. Repair jobs are throttled to avoid saturating data node bandwidth during normal operation.
Garbage collection: deleting an object marks its metadata record as deleted and records the chunk IDs for GC. A background sweeper periodically reads GC-eligible chunk IDs and issues delete commands to the data nodes, then removes the metadata tombstone. A reference-count scheme handles the multipart case where multiple logical objects may share chunks.
Capacity Estimate
At 1 EB of logical data with 1.5× average storage amplification (mixed replication/EC), the physical storage needed is ~1.5 EB spread across data nodes. At 20 TB usable per node, that is ~75,000 nodes. Metadata at 1 KB/object for 100B objects is ~100 TB, manageable in a sharded database cluster.
Common Mistakes
- Committing metadata before data is durable: if the service records the key before the data nodes acknowledge, a subsequent GET can return a 404 or corrupt bytes.
- Forgetting failure domains: three replicas on nodes in the same rack fail together. Replicas must span racks or availability zones.
- Ignoring GC: a delete API that just removes metadata but never reclaims disk space is a common design omission.
- Overcomplicating listing: prefix listing over billions of keys requires an ordered index on
(bucket, key)— a plain hash index does not support range scans.