Amazon S3
Amazon S3 (Simple Storage Service) is AWS's object storage service: you put a file (an object) into a bucket under a key, and later get it back by that key over HTTP. It stores trillions of objects for millions of customers, and its API has become the de facto standard for object storage. Google Cloud Storage, Azure Blob Storage, Cloudflare R2 and self-hosted systems like MinIO and Ceph all work the same way, and many speak the S3 API directly.
The properties that matter in a design:
- Effectively unlimited capacity: you never provision disks or plan capacity. A bucket can hold any number of objects, and single objects can be terabytes.
- Extreme durability: S3 Standard is designed for 99.999999999% ("eleven nines") durability by storing data redundantly across multiple Availability Zones. Losing an object to hardware failure is, for practical purposes, not something you plan for.
- Simple key-value model over HTTP:
PUT,GET,DELETE,LIST, with objects replaced as a whole rather than edited in place. - Strong consistency: once a write succeeds, every subsequent read and list sees it.
- Cheap at rest, priced per request and per byte transferred out: storage costs a couple of cents per GB-month in the standard tier and far less in archival tiers.
- Massively parallel: aggregate throughput scales with the number of clients and connections, to hundreds of gigabits per second for a single bucket.
S3 shows up in almost every system design interview that involves files: photos in Instagram, videos in YouTube, documents in Google Drive, attachments in Slack, build artifacts in CI/CD, raw events in a data lake, backups for everything. The expected pattern is always the same: store the bytes in object storage, store the metadata in a database, and keep the bytes off your application servers using pre-signed URLs and a CDN. You should know that pattern cold, plus the details interviewers like to probe: multipart uploads, consistency, request-rate limits, storage classes and lifecycle rules.
The Data Model
Buckets are containers with globally unique names, each living in one AWS region. Objects are the stored items: the bytes, plus a small amount of metadata (content type, cache headers, user-defined key-value pairs) and a key that identifies the object within the bucket.
s3://photos-prod/users/8812/albums/42/IMG_1031.jpg
└─ bucket ─┘ └──────────────── key ───────────────┘
A few things about the model trip people up:
- The namespace is flat. There are no real directories.
users/8812/albums/42/IMG_1031.jpgis a single key that happens to contain slashes. Listing with aprefixand adelimitermakes it look like folders, but "renaming a folder" means copying and deleting every object under that prefix. - Objects are immutable. You can't append to or edit part of an object. A
PUTto an existing key replaces the whole object. To change one byte of a 10 GB file, you rewrite 10 GB, which is why systems like Google Drive or Dropbox split files into chunks and store each chunk as its own object. - Size limits. A single
PUTcan upload up to 5 GB. Larger objects must use multipart upload, and objects can be several terabytes in total. - ETags identify an object's content (for simple uploads, the MD5 of the bytes), which clients use for caching and integrity checks.
- Versioning (opt-in per bucket) keeps every version of every object. Overwrites create a new version and deletes add a "delete marker," so accidental deletes and overwrites can be undone.
- Conditional writes:
PUTwithIf-None-Match: *succeeds only if the key doesn't exist yet, andIf-Match: <etag>succeeds only if the object hasn't changed. These let you use S3 for simple compare-and-swap coordination, such as committing a manifest file.
The core API is small:
PUT /users/8812/avatar.jpg # upload (whole object)
GET /users/8812/avatar.jpg # download, optionally with Range: bytes=0-1048575
HEAD /users/8812/avatar.jpg # metadata only
DELETE /users/8812/avatar.jpg
GET /?list-type=2&prefix=users/8812/&continuation-token=... # list, 1,000 keys per page