Object storage (S3-style)
Store files as whole objects under bucket + key, over HTTP: virtually unlimited, very durable and cheap per GB, but you rewrite whole objects, pay per request, and keep metadata and queries in a database.
How it works
- An object is bytes plus metadata under a bucket + key; the namespace is flat and prefixes just group keys.
- You replace whole objects, never edit bytes in place; a rename is a copy plus a delete.
- Multipart upload sends parts in parallel and retries only a failed part; use it from ~100 MB.
- Presigned URLs let clients move bytes straight to storage, so your API servers never proxy them.
- Keep bytes in object storage and metadata in a database; serve hot objects through a CDN.
Check yourself
Answer to mark it learned; your answers aren't scored.
Users upload videos up to 2 GB through your API servers, which stream them to S3. At peak, API workers saturate and uploads time out. Best fix?
Go deeper
Full explanation
Object storage (Amazon S3, Google Cloud Storage, Azure Blob) keeps objects (bytes plus metadata) in a bucket under a key. The namespace is flat: the / in videos/2026/a.mp4 is just a character, and prefixes only group keys.
- Durability: S3 Standard stores data across at least 3 AZs and is designed for 11 nines. Since Dec 2020, a read after a successful write returns the new object.
- Whole-object writes: in general-purpose buckets you can't edit bytes in place; you upload a new version. A rename is a copy plus a delete.
- Multipart upload: split a big file into parts (5 MiB–5 GiB, up to 10,000), upload them in parallel and retry only the part that failed.
- Presigned URLs: your API signs a short-lived URL, so the client uploads or downloads directly, never through your servers.
- Storage classes: the price per GB falls as retrieval gets slower or costlier; lifecycle rules move or delete objects by age.
The classic pattern: bytes in object storage, metadata and search in a database, delivery through a CDNs and edge caching.
Code Presigned URLs and multipart upload with boto3
import boto3
from boto3.s3.transfer import TransferConfig
s3 = boto3.client("s3")
BUCKET = "media-uploads" # example bucket
MB = 1024 * 1024
def upload_url(user_id: str, upload_id: str, content_type: str) -> str:
key = f"raw/{user_id}/{upload_id}" # the server picks the key, never the client
return s3.generate_presigned_url(
"put_object",
Params={"Bucket": BUCKET, "Key": key, "ContentType": content_type},
ExpiresIn=900, # 15 min: a presigned URL is a bearer token
)
def download_url(key: str) -> str:
return s3.generate_presigned_url(
"get_object", Params={"Bucket": BUCKET, "Key": key}, ExpiresIn=300
)
# Server-side large file: the SDK splits it into parallel parts
cfg = TransferConfig(
multipart_threshold=100 * MB, # AWS suggests multipart from ~100 MB
multipart_chunksize=100 * MB,
max_concurrency=8,
)
s3.upload_file("render.mp4", BUCKET, "renders/2026/render.mp4", Config=cfg)Real example
A video app accepts uploads up to 5 GB from phones. The API checks quota, writes an uploads row as pending and returns presigned URLs for each part. The phone uploads 100 MB parts, 4 at a time; on a flaky network only the dropped part is retried. Completing the upload fires an ObjectCreated event; a worker transcodes, stores renditions and flips the row to ready. A lifecycle rule aborts incomplete uploads after 7 days. API servers never touch a video byte.
Trade-offs +3 · −3
+ You gain
- Virtually unlimited capacity, with no servers or disks to manage.
- Very durable and cheap per GB, with colder classes for archives.
- Throughput scales out: parallel requests across prefixes reach tens of thousands per second.
− You pay
- Higher per-request latency than a disk or cache: ~100–200 ms for small objects, per AWS.
- No partial updates, appends or atomic renames in general-purpose buckets.
- You pay per request: millions of tiny objects can cost more in requests than in storage.
Use it when
Files and blobs written once and read many times by key: images, video, backups, logs, ML datasets and model weights, data-lake tables, static sites.
Avoid it when
Small records you update or query by field (use a database), low-latency random reads (use a cache or block storage), or workloads that need in-place file edits.
Numbers to know 5
- S3 Standard: designed for 11 nines (99.999999999%) durability, data in at least 3 AZs.
- Multipart: parts of 5 MiB–5 GiB, at most 10,000; max object 50 TB since Dec 2025 (10,000 × 5 GiB).
- Per partitioned prefix: at least 3,500 writes/s and 11,000 reads/s (AWS docs, Nov 2026); spread keys across prefixes to go higher.
- us-east-1 list price (Nov 2026), per GB-month: Standard $0.023, Standard-IA $0.0125, Glacier Instant Retrieval $0.004; PUTs $0.005 per 1,000.
- Presigned URLs: up to 7 days with IAM user keys; with role credentials they expire with the session.
Common pitfalls 4
- Proxying uploads through API servers: you pay twice in bandwidth and tie up workers for minutes.
- Never aborting failed multipart uploads: orphaned parts are billed until an
AbortIncompleteMultipartUploadlifecycle rule removes them. - Treating it like a filesystem: listing prefixes to find files, or "renaming" millions of objects.
- Moving tiny or short-lived objects to cold classes: Glacier Instant Retrieval bills at least 128 KB and 90 days each.
Interview questions 3
Answer out loud first, then reveal.
Design uploads of files up to 5 GB from mobile clients.Show answer
The API never touches the bytes. It authenticates, checks quota, picks the key itself, records a pending row and returns presigned URLs, one per multipart part. The client uploads parts in parallel and retries only failed ones. Completion fires an ObjectCreated event; a worker validates, scans and processes, then marks the row ready. A lifecycle rule aborts incomplete uploads, and downloads go through a CDN with short-lived signed URLs.
Why not store user files in the database as blobs?Show answer
Each store is good at a different job. A database is built for small rows, indexes and transactions; multi-MB blobs bloat its backups, replication and buffer cache, and every byte flows through its connections. Object storage is cheaper per GB, scales out, is very durable and works with CDNs and presigned URLs. So I keep bytes in S3 and a metadata row in Postgres: key, owner, size, checksum, status.
Is S3 eventually consistent?Show answer
Not anymore. Since December 2020, S3 gives strong read-after-write consistency for new objects, overwrites and LIST, at no extra cost. What it doesn't give is multi-object transactions or locks: two writers to the same key race and the latest wins. So I give each upload a unique key, use conditional writes when overwrites must not happen, and keep cross-object invariants in the database.