Design a Blob Store
🪣 What is a blob store? It is a service that keeps large chunks of data ("blobs": photos, videos, backups, logs) under a name. Data lives in buckets, and inside a bucket every blob is an object with a key such as
photos/cat.jpg. Clients upload objects, download them, list them by prefix and delete them. Amazon S3 is the best-known example.
In a high-level design interview the blob store is about replication and metadata databases (see /system-design/blob-store). In a low-level design interview it is about the object model: what a version is, what "delete" means when history is kept, how a big upload is split into parts, and how data is cut into chunks for download. All of that fits in a few small classes.
Requirements
"Design an object store like S3. Users create buckets and store files in them. Files can be large, and we keep old versions."
That is the whole prompt. The questions below turn it into rules.
Clarifying Questions
You: What is an object? Do we need real folders?
Interviewer: An object is a key and its data, inside a bucket. Keys are flat strings. A key like logs/2024/a.txt has slashes in it, but there are no real folders; listing by prefix is enough.
You: What happens when someone writes to a key that already exists?
Interviewer: Versioning is always on. Every write creates a new version, numbered 1, 2, 3 and so on per key. Reads get the latest version by default, or any older one by number.
You: And delete? Does it erase the history?
Interviewer: No. Delete hides the object: reading the latest version fails, and listings skip it. Old versions stay readable by number. A later write brings the key back.
You: How do large files get in? One huge request is fragile.
Interviewer: Multipart upload. The client starts an upload, sends numbered parts in any order, possibly in parallel, and then completes it. A part that is sent again replaces the earlier copy. The object only appears when the upload completes.
You: And large files going out?
Interviewer: We store data in fixed-size chunks, set when the store starts. A client can download one chunk at a time by index, so it can resume or download in parallel.
You: Do we need to delete buckets, set permissions or expire old data?
Interviewer: No. Creating buckets is enough for now. Retention rules are a possible follow-up.
You: Will this run on many threads?
Interviewer: Assume a single thread first.
The answer about delete changes the whole model. If delete erased the key, a version list would be a small add-on. Because delete is just another event in the history, the history becomes the object, and delete is one more entry in it.
💡 Interview tip: For any storage problem, ask "what does overwrite do?" and "what does delete do?" first. Together they decide whether your core structure is a map of current values or an append-only history, and switching later means rewriting everything.
Final Requirements
- Clients create buckets with unique names.
- Inside a bucket, an object is a key plus its history of versions. Every successful write (a simple put or a completed multipart upload) adds the next version number of that key, starting at 1.
- A read names a version number, or
0for the latest. Reading a missing bucket, key or version returns nothing. - Deleting an object adds a delete marker as the next version. While the latest version is a delete marker, reading the latest returns nothing and listings skip the key. Older versions stay readable. Deleting a key that is missing or already deleted fails.
- The store cuts every version's data into chunks of a fixed size. A client can read chunk
iof any version. The last chunk may be shorter. - A multipart upload is started for a bucket and key and gets a unique upload id. Parts have numbers; they can arrive in any order, and a repeated part number replaces the old part. Completing the upload joins the parts in part-number order and creates the next version. An upload with no parts cannot complete. After completion the id is no longer valid.
- Listing a bucket with a prefix returns the keys that start with the prefix and are not deleted, in sorted order.
Out of scope
- Deleting buckets, permissions, encryption and checksums.
- Retention rules and cleaning up abandoned uploads (we sketch them in Extensibility).
- Disks, replication and machines (that is the high-level design).
- Several callers at the same time (back in Extensibility).