Object storage (Amazon S3, Google Cloud Storage, Azure Blob Storage) stores files as immutable objects addressed by a key in a flat namespace and accessed over HTTP. It scales to exabytes, is designed for eleven nines of durability and costs a few cents per gigabyte per month. Almost every system that handles images, video, backups, logs or datasets keeps the bytes in an object store and only the metadata in a database.
Think of it like
Valet parking
You hand over your car and receive a ticket. You do not know or care which level or spot it is parked in, and you cannot repaint it while it is parked; to change it, you swap in a different car under the same ticket. The garage handles security, redundancy and scale, and anyone holding a valid ticket (a pre-signed URL) can collect the car without visiting the front desk.
Block vs file vs object storage
Block storage
- A raw disk of fixed-size blocks, addressed by block number
- Attached to one server; a file system or database sits on top
- Lowest latency, in-place updates of any byte
- AWS EBS, SAN volumes, local NVMe
File storage
- Hierarchical directories with POSIX semantics (open, seek, lock)
- Shared by many servers over NFS or SMB
- Metadata server becomes a bottleneck at billions of files
- AWS EFS, NetApp, Azure Files
Object storage
- Whole objects via HTTP
PUT,GET,DELETE; no partial in-place writes - Flat namespace of keys plus rich metadata
- Practically unlimited scale, higher latency (tens of milliseconds to first byte)
- S3, GCS, Azure Blob, Ceph RGW, MinIO
| Block | File | Object | |
|---|---|---|---|
| Interface | SCSI/NVMe block device | POSIX over NFS/SMB | HTTP REST API |
| Unit | Block (e.g. 4 KB) | File in a directory tree | Object (bytes + metadata) under a key |
| Mutability | Overwrite any block | Overwrite any byte range | Replace the whole object |
| Sharing | One host (mostly) | Many hosts | Anyone with credentials, anywhere |
| Typical use | Database volumes, boot disks | Shared home dirs, legacy apps | Media, backups, data lakes, static sites |
| Relative cost | Highest | High | Lowest |
The S3 data model
- Bucket
- A container with a globally unique name, created in one region, with its own access policy, versioning and lifecycle settings.
- Key
- The object's name within the bucket, up to 1,024 bytes, e.g.
photos/2026/10/cat.jpg. - Object
- The data (0 bytes to 50 TB in S3, raised from 5 TB in late 2025) plus metadata. Objects are replaced, never edited in place.
- Metadata
- System metadata (
Content-Type,Content-Length,ETag,Last-Modified) and user metadata (x-amz-meta-*headers). - Version ID
- With versioning on, every overwrite or delete keeps the previous versions, protecting against accidents.
- Prefix and delimiter
- List operations filter keys by prefix and can group them at a delimiter (usually
/), which is how consoles fake folders.
# Upload (replace) an object
PUT /photos/2026/10/cat.jpg HTTP/1.1
Host: acme-media.s3.us-east-1.amazonaws.com
Content-Type: image/jpeg
x-amz-meta-uploaded-by: user-42
# Download only the first 1 MB (range reads enable parallel and resumable downloads)
GET /photos/2026/10/cat.jpg HTTP/1.1
Range: bytes=0-1048575
# List "folders" under photos/2026/ (1,000 keys per page, paginated)
GET /?list-type=2&prefix=photos/2026/&delimiter=/
# Delete
DELETE /photos/2026/10/cat.jpgS3 automatically partitions buckets by key prefix and supports at least 3,500 writes and 5,500 reads per second per prefix, scaling further as it splits busy prefixes. Spreading very hot workloads across many prefixes (for example by including a hash or date in the key) raises the ceiling.
Durability: replication and erasure coding
Designed durability
99.999999999%
eleven nines per year
In practice
1 in 10M
objects lost once every 10,000 years, on average
Designed availability
99.99%
S3 Standard; the SLA is 99.9%
Failure domains
≥ 3 AZs
S3 Standard spreads data across zones
Replication (3 copies)
- Store the full object on 3 nodes in different zones
- 200% storage overhead
- Fast reads and simple, cheap repair (copy a replica)
- Survives the loss of any 2 copies
Erasure coding (e.g. 8 + 4)
- Split into k = 8 data fragments, compute m = 4 parity fragments (Reed-Solomon)
- Any 8 of the 12 fragments rebuild the object: survives 4 failures
- Only 50% storage overhead
- Repair reads k fragments over the network; more CPU; worse for tiny objects
Eleven nines does not come from the code alone. It comes from placing fragments in independent failure domains (disks, racks, availability zones), checksumming every fragment to catch silent bit rot, continuously scrubbing data in the background, and above all repairing quickly: data is lost only if more than m fragments fail before the first failure is repaired, so shrinking the repair window from days to minutes multiplies durability.
Consistency
Since December 2020, S3 provides strong read-after-write consistency for every PUT, DELETE and LIST: once a write returns success, every subsequent read sees it. (Before that, overwrites and listings were only eventually consistent, which caused many subtle bugs.) Concurrent writers to the same key are resolved by last writer wins, with no locking.
- Conditional writes:
If-None-Match: *creates an object only if the key does not exist, andIf-Match: <etag>overwrites only if nobody changed it since you read it. Together they enable safe compare-and-swap on objects. - Versioning: keeps previous versions so an accidental overwrite or delete can be undone.
- Object Lock: write-once-read-many retention for compliance and ransomware protection.
Uploading large files: multipart upload
- 1
Initiate
CreateMultipartUploadreturns anUploadId. - 2
Upload parts in parallel
Send parts of 5 MiB to 5 GiB each (the last part may be smaller), up to 10,000 parts. Each response returns the part's
ETag. - 3
Retry only what failed
A network blip costs one part, not the whole 50 GB upload. Parts can even be uploaded from different machines.
- 4
Complete
CompleteMultipartUploadwith the ordered list of part numbers and ETags. The object appears atomically. - 5
Or abort
AbortMultipartUploadfrees the stored parts. Abandoned parts are invisible but still billed.
A single PUT can upload up to 5 GB, but multipart is recommended above about 100 MB and required beyond 5 GB, up to the 50 TB object limit. It also lets you start uploading a stream before you know its total size.
Pre-signed URLs and direct uploads
Routing gigabytes of user uploads through your application servers wastes bandwidth, memory and threads. Instead, the app server authorizes the request and returns a pre-signed URL: a normal S3 URL carrying the signer's access key ID, an expiry and an HMAC signature over the method, bucket, key and selected headers. The client then talks to the object store directly, and the bucket stays private.
- Keep expiries short (minutes for uploads) and sign the
Content-Typeso the client cannot switch it. - To cap upload size, use a pre-signed POST policy with a
content-length-rangecondition; a pre-signed PUT cannot enforce a maximum by itself. - Turn on Block Public Access for the bucket and grant the CDN access via origin access control.
- A pre-signed URL is a bearer token: anyone who has it can use it until it expires, so never log it.
Storage classes and lifecycle rules
| Class | Access pattern | First-byte latency | Min. storage duration | Approx. $/GB-month |
|---|---|---|---|---|
| S3 Standard | Hot, frequently read | Milliseconds | None | 0.023 |
| S3 Intelligent-Tiering | Unknown or changing | Milliseconds (frequent and infrequent tiers) | None | Varies by tier, plus a small monitoring fee |
| S3 Standard-IA | Read about monthly; per-GB retrieval fee | Milliseconds | 30 days | 0.0125 |
| S3 One Zone-IA | Re-creatable data; single AZ | Milliseconds | 30 days | 0.01 |
| Glacier Instant Retrieval | Archive read about quarterly | Milliseconds | 90 days | 0.004 |
| Glacier Flexible Retrieval | Archive; restore first | Minutes to 12 hours | 90 days | 0.0036 |
| Glacier Deep Archive | Compliance, rarely if ever read | Up to 12 hours (48 for bulk) | 180 days | 0.00099 |
{
"Rules": [
{
"ID": "logs-tiering",
"Status": "Enabled",
"Filter": { "Prefix": "logs/" },
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER" }
],
"Expiration": { "Days": 365 },
"NoncurrentVersionExpiration": { "NoncurrentDays": 30 },
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
}
]
}The pattern: blobs in the object store, metadata in the database
Large binary blobs do not belong in a relational database: they bloat backups, evict hot rows from the buffer pool, slow replication and cost several times more per gigabyte. Store the bytes in the object store and a small metadata row pointing to them in the database, where you can index, join and query it.
| Column | Type | Purpose |
|---|---|---|
id | BIGINT / UUID | Primary key exposed to clients |
owner_id | BIGINT | Authorization and "my files" queries |
storage_key | TEXT | Object key, e.g. uploads/u42/7f3c.jpg (never a full public URL) |
size_bytes, content_type | BIGINT, TEXT | Quotas, validation, response headers |
sha256 | BYTEA | Integrity checks and deduplication |
status | ENUM | pending, ready, failed, deleted |
created_at | TIMESTAMPTZ | Sorting and retention |
Designing an object store
A classic interview question is "design S3". The central idea is to separate metadata from data: a strongly consistent, sharded metadata service maps bucket + key to where the fragments live, while a large fleet of simple data nodes stores the bytes.
- Front end: stateless; handles auth, request routing, chunking and erasure coding.
- Metadata service: a sharded, replicated key-value store (partitioned by
bucket + key) supporting prefix listing. This is the hardest part to scale. - Data nodes: append fragments into large files on local disks to avoid file-system overhead per object, and keep an in-memory index of offsets.
- Placement and repair: tracks node health and capacity, chooses placements across failure domains and drives re-replication.
- Background jobs: garbage collection of deleted or unreferenced fragments, scrubbing, lifecycle transitions.
Implementation
The server authorizes the user, picks the key and signs a short-lived URL; the client uploads or downloads directly.
import uuid
import boto3
s3 = boto3.client("s3", region_name="us-east-1")
BUCKET = "acme-user-uploads"
def create_upload_url(user_id: str, content_type: str) -> dict:
key = f"uploads/{user_id}/{uuid.uuid4()}"
url = s3.generate_presigned_url(
ClientMethod="put_object",
Params={"Bucket": BUCKET, "Key": key, "ContentType": content_type},
ExpiresIn=900, # 15 minutes
)
# Insert (key, user_id, status="pending") into the metadata DB here.
return {"key": key, "uploadUrl": url}
def create_download_url(key: str) -> str:
return s3.generate_presigned_url(
ClientMethod="get_object",
Params={"Bucket": BUCKET, "Key": key},
ExpiresIn=300,
)Key takeaways
- Block storage is a raw disk, file storage is a shared directory tree, object storage is an HTTP key-value store for immutable blobs.
- S3 objects live in buckets under keys in a flat namespace; folders are just key prefixes.
- Eleven nines of durability come from erasure coding or replication across zones plus checksums and fast repair.
- Use multipart uploads for large files and pre-signed URLs so bytes bypass your application servers.
- Keep blobs in the object store and metadata in a database, and plan for the two to drift.
- Lifecycle rules and storage classes cut cost dramatically for data that cools over time.
Common pitfalls
- Storing large blobs in the relational database, bloating backups and replication.
- Proxying uploads and downloads through app servers instead of using pre-signed URLs and a CDN.
- Making buckets public to serve files instead of using CDN origin access control or signed URLs.
- Treating object storage like a file system: in-place edits, renames or LIST-based queries.
- Forgetting lifecycle rules for incomplete multipart uploads and old versions, which quietly inflate the bill.
Interview tips
- Whenever users upload files, say "bytes go to object storage, metadata goes to the database" early.
- Describe the pre-signed upload flow step by step, including how you learn the upload finished.
- Know the difference between durability and availability, and between replication and erasure coding overhead.
- If asked to design S3, separate the metadata service from data nodes and explain the commit point.
Real-world applications
- User uploads: profile photos, documents, attachments.
- Video and image pipelines feeding a CDN. See Design a Video Streaming Platform.
- Backups, database snapshots and log archives.
- Data lakes queried by Spark, Trino or Athena.
- Static website and front-end asset hosting.
Test yourself
Why can't you edit the middle of an S3 object in place?
Related topics
Finished this lesson? Track it to see your progress on the roadmap.