AlgoViz

Amazon S3

medium 30 min

Amazon S3 stores objects, whole files with a key and metadata, in buckets that you reach over HTTP.

Video lesson · Chapter 1 of 5

A photo becomes an object

0:00 / 3:57

Amazon S3 in 90 seconds

1:30Reel coming soon

Theory

Read or listen first. About 2 min.

What it is

Amazon Simple Storage Service (S3) is a managed object store. You put bytes under a name, the key, into a bucket, and get them back by the same name. There are no disks to choose and no size to plan.

An object is written as a whole and read as a whole or in byte ranges. You do not open it and change the middle, as you would with a file. The slashes in a key look like folders, but they are only part of the name.

Everything happens over HTTP requests that are signed and checked against policies.

Why it exists

Files that users upload, logs, backups and data sets grow without end. Keeping them on the disks of your own servers means resizing, copying, replacing drives and worrying about a lost data center. S3 turns that into a service with one simple interface.

The trade is latency and flexibility. A first byte takes roughly 100 to 200 milliseconds for small objects, and there is no locking or partial update. That is fine for images and archives, and wrong for the pages of a database.

A short history

  1. 14 March 2006

    Amazon announces S3.

  2. 1 December 2020

    All reads, writes and listings become strongly consistent, at no extra cost.

  3. 5 January 2023

    Every new object is encrypted at rest by default.

  4. August and November 2024

    Conditional writes arrive: first "only if the key is new", then "only if the object is unchanged".

  5. 2 December 2025

    The largest object grows from 5 TB to 50 TB.

Words to know

Bucket
A container for objects in one region, with its own settings and policy.
Object
Data plus metadata, under one key and, with versioning, one version ID.
Key
The object's full name, up to 1,024 bytes.
Prefix
The beginning of keys, such as logs/2026/. Used to list and to spread load.
Storage class
A price and access profile of an object.
Presigned URL
A link that carries a signature and an end time for one operation.
ETag
A tag that changes when the object changes; not always a checksum of it.
Availability Zone
One or more separate data centers of a region.
Delete marker
A placeholder that hides an object in a versioned bucket.

How it works

Step through the idea, or press Play.

Step 1 of 3

PUT a key. Signed, checked, stored across at least three zones, then 200

Understand it

Start here

The seed vault

Imagine a seed vault. Every packet has a drawer number, a keeper has the list, and the drawers are kept in three mountains.

Numbered drawers in three mountains
K7K7K7LISTK7: emptyK8: beanK7One packet, one drawer number

The number is the only thing a gardener needs. Mountains and drawers are the vault's business.

The idea

Buckets, objects and keys

PartWhat it isWorth knowing
BucketContainer in one regionNames have 3 to 63 characters and are shared with all accounts, unless you use your account's own regional namespace
KeyFlat nameusers/123/photo.jpg is one string; consoles draw folders from it
ObjectBytes plus system and own metadataUp to 50 TB (48.8 TiB); replaced as a whole
Version IDIdentifies one versionOnly when versioning is on
  • Durable

    Designed for eleven nines. Data is checked and repaired all the time.

  • No capacity planning

    Any number of objects in a bucket. Request rates grow with prefixes.

  • Classes by use

    Eight classes, and rules that move or delete objects.

  • Consistent

    A GET or LIST after a successful PUT or DELETE sees it.

  • Guarded

    Private by default, encrypted by default, policies, locks, versions.

  • Connected

    Events, Athena, EMR, Lambda, CloudFront and many other services read it.

The general ideas, and how to build such a store, are in object storage and blob store design.

What eleven nines mean

107 objects×10−11 a year=10−4 a year=1 object in 10,000 years10^{7}\ \text{objects} \times 10^{-11}\ \text{a year} = 10^{-4}\ \text{a year} = 1\ \text{object in}\ 10{,}000\ \text{years}
A design goal for losing data to hardware, on average. It says nothing about your own deletes, bugs or a leaked key. Availability is a different number: 99.99% by design for S3 Standard, 99.9% a month in the service agreement.

Inside

How a request is served

Front end, namespace, storage

Our app sends PUT and GET requests to Amazon S3 in one region. A REST front end looks keys up in a namespace, which points to drives in Availability Zones A, B and C.
The shape AWS describes: a REST front end, a namespace service, a storage fleet of hard drives, and background services.
  1. 1

    Resolve

    bucket.s3.region.amazonaws.com resolves to one of many front-end servers.

  2. 2

    Check

    Signature Version 4 proves the caller. IAM, bucket policy, access points and Block Public Access are evaluated together; an explicit deny always wins.

  3. 3

    Find

    The namespace maps bucket and key to places and metadata.

  4. 4

    Write

    Data goes to several devices in at least three zones, with checksums. Only then is the new object visible and the answer 200.

  5. 5

    Read

    Pieces are fetched, slow or broken drives are worked around, and the bytes are returned.

  6. 6

    Repair

    Integrity checks run all the time; lost redundancy is rebuilt on other devices.

AWS has written that S3 uses plain copies for some data and erasure coding for the rest: an object becomes kk data shards plus mm parity shards, and any kk of them are enough. It also spreads each customer's data over very many drives, so that one busy customer does not heat up a few of them.

Erasure coding, as an example with 4 + 2

The numbers are an example. AWS does not publish the code of each class. Space used here: 6/4 = 1.5 times, against 3 times for three copies.

Consistency

What readers see

Read after write, and two writers

Strong consistency is per key. Both writers get success and the latest timestamp wins; S3 does not lock.

To avoid lost updates use conditional writes. If-None-Match: * creates only if the key is new. If-Match with an ETag replaces only the version you read. A failed condition returns 412; a race can return 409, and you retry. This gives you a safe way to create a file once, or to swap a small pointer object. There are still no transactions over several keys.

Coordinating writers

NeedUse
Keep both resultsDifferent keys, or versioning
Create onceIf-None-Match: *
Change only what I readIf-Match with the ETag, then retry
Change several objects togetherWrite all data first, then swap one pointer object, or keep the truth in a database

Speed

Prefixes, ranges and parallel work

AWS states at least 3,500 writes (PUT, COPY, POST, DELETE) or 11,000 reads (GET, HEAD) a second for each partitioned prefix. Many teams still quote the earlier figure of 5,500 reads. S3 splits busy prefixes by itself, but gradually; until then you may see 503 Slow Down.

How many prefixes?

n=⌈100,000 GET/s11,000⌉=1011,000×86,400≈950 million reads a day per prefixn = \left\lceil \frac{100{,}000\ \text{GET/s}}{11{,}000} \right\rceil = 10 \qquad 11{,}000 \times 86{,}400 \approx 950\ \text{million reads a day per prefix}
Sixteen prefixes, one hexadecimal character of a hash, leave some room. For reads of popular objects a CDN is usually the better answer.

Spreading keys

KeyEffect
avatars/u123.jpgAll under one prefix until S3 splits it
7/avatars/u123.jpgOne of 16 prefixes by a hash of the name
7f/avatars/u123.jpgOne of 256
2026-11-23/log-0001Every day starts with a cold prefix; avoid at high rates
The slash has no special meaning. The cost of hashing: you can no longer list in a natural order.
  • Multipart upload

    Parts of 5 MiB to 5 GiB, up to 10,000, in parallel, each retried alone. Advised from 100 MB; a single PUT ends at 5 GB.

  • Byte ranges

    Fetch parts of an object in parallel, or only the first kilobytes.

  • Transfer Acceleration

    Enter at a nearby CloudFront location and travel on AWS's network. Extra price; test whether it helps.

  • S3 Express One Zone

    Single-digit milliseconds in one zone, in directory buckets. Supports appends.

A multipart upload

Parts of unfinished uploads are stored and billed until you abort them. Add a lifecycle rule that does it.

Access

Presigned URLs

Files go around the app

A browser asks the API for a URL, uploads directly to a private bucket, and downloads through a CDN that fills itself from the bucket.
The app decides and signs. The bytes travel between the browser, the bucket and the CDN.

A presigned URL holds the operation, bucket, key, end time and a signature. Whoever has it can use it, as often as they like, until it ends. Keep uploads to about 15 minutes. The longest life is 7 days with an IAM user's key; with a role it ends with the role's session.

  1. 1

    Ask

    The client tells the app the name, type and size. The app checks the user and the quota.

  2. 2

    Sign

    The app chooses the key itself, never the client, and signs a PUT with the content type, or a POST policy with a size range.

  3. 3

    Upload

    The client sends the file to S3.

  4. 4

    Confirm

    An event or a call from the client makes the app check the object, scan it and mark it ready.

A presigned PUT cannot limit the size by itself unless you sign the exact length; a presigned POST can, with content-length-range. More in file upload APIs. Events are delivered at least once, so make the handler idempotent.

Classes

Storage classes and lifecycle rules

Classes by design, November 2026

ClassForAvailability, zonesMinimumRead
StandardOften read99.99%, 3 or morenoneMilliseconds
Intelligent-TieringUnknown pattern99.9%, 3 or morenone; monitoring fee per objectMilliseconds, unless archive tiers are on
Express One ZoneLowest latency99.95%, 1noneSingle-digit ms
Standard-IAAbout monthly99.9%, 3 or more30 days, 128 KBMilliseconds, fee per GB
One Zone-IACan be made again99.5%, 130 days, 128 KBMilliseconds, fee per GB
Glacier Instant RetrievalAbout quarterly99.9%, 3 or more90 days, 128 KBMilliseconds, fee per GB
Glacier Flexible RetrievalAbout yearly99.99% after restore, 3 or more90 days1-5 min expedited, 3-5 h standard, 5-12 h bulk
Glacier Deep ArchiveLess than yearly99.99% after restore, 3 or more180 daysWithin 12 h standard, 48 h bulk
All are designed for eleven nines of durability, but the one-zone classes can be lost with their zone.

Which class?

JSON
{  "Rules": [    {      "ID": "archive-old-logs",      "Status": "Enabled",      "Filter": { "Prefix": "logs/" },      "Transitions": [        { "Days": 30, "StorageClass": "STANDARD_IA" },        { "Days": 90, "StorageClass": "GLACIER" }      ],      "Expiration": { "Days": 365 },      "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }    }  ]}
Apply it with aws s3api put-bucket-lifecycle-configuration. Objects below 128 KB are not moved by default, because the move costs more than it saves.

Is the rule worth it? An example with assumed prices

30365⋅1.00+60365⋅0.55+275365⋅0.16⏟average price against Standard≈0.08+0.09+0.12=0.29\underbrace{\tfrac{30}{365}\cdot 1.00 + \tfrac{60}{365}\cdot 0.55 + \tfrac{275}{365}\cdot 0.16}_{\text{average price against Standard}} \approx 0.08 + 0.09 + 0.12 = 0.29
Assumed prices: Standard-IA 55% and Flexible Retrieval 16% of Standard. The year costs about 29%, so 71% is saved, before requests, transitions and retrievals. Put in your region's prices.

Protection

Versions, locks and copies

Delete and get back

ToolProtects fromLimits
VersioningOverwrites and deletes by mistakeOld versions cost; add a rule for them
MFA deleteDeleting versions with stolen credentialsSet by the root user, awkward to automate
Object Lock, governanceMost usersSome may override with a special permission
Object Lock, complianceEveryone, root included, until the dateCannot be shortened: test first
Cross-Region ReplicationLoss of a region, distanceAsynchronous, needs versioning on both sides, new objects only
Replication Time ControlUnknown lagDesigned for 99.9% of objects within 15 minutes
Existing objects need Batch Replication. Replication copies mistakes too, so it is not a backup by itself.

Security

Private by default, and keep it so

Encryption at rest

KindKeysNotes
SSE-S3 (default)S3 manages themNo extra work
SSE-KMSIn AWS KMSKey permissions and key use in CloudTrail; KMS request costs and limits
SSE-CYou send the key on each requestBlocked by default for new buckets since April 2026
Client-sideYou encrypt before uploadS3 never sees plain data
JSON
{  "Version": "2012-10-17",  "Statement": [    {      "Sid": "PartnerRead",      "Effect": "Allow",      "Principal": { "AWS": "arn:aws:iam::123456789012:role/reader" },      "Action": "s3:GetObject",      "Resource": "arn:aws:s3:::my-bucket/shared/*"    },    {      "Sid": "PartnerList",      "Effect": "Allow",      "Principal": { "AWS": "arn:aws:iam::123456789012:role/reader" },      "Action": "s3:ListBucket",      "Resource": "arn:aws:s3:::my-bucket",      "Condition": { "StringLike": { "s3:prefix": "shared/*" } }    }  ]}
Another account's role may read one prefix. Their own account must allow it too. GetObject applies to objects, ListBucket to the bucket.

Block Public Access is on for new buckets; leave it on, and serve public files through a CDN that alone may read the bucket. Log access, and give each program only its prefix.

Data

Analytics and what is new

  • Data lake

    Raw files in Parquet, read by Athena, EMR, Spark or Redshift Spectrum. Keep many rows in each file: thousands of tiny objects are slow and dear.

  • S3 Tables

    Buckets made for Apache Iceberg tables, with maintenance included.

  • S3 Vectors

    Vector storage and search on S3.

  • S3 Select

    Closed to new customers. Use Athena or read ranges of Parquet files instead.

Decide

When to choose it, and when not

Choose S3 for

  • Images, videos, documents, logs, backups
  • Written once and read many times
  • Data lakes and training data
  • Static sites behind a CDN
  • Archives with lifecycle rules
  • Collecting logs of many systems

Not for

  • Look-ups below 10 ms: DynamoDB or a cache (Express One Zone narrows this)
  • Frequent small changes in a file
  • POSIX locks, appends and seeks: EFS
  • Transactions over several items
  • Counters and sessions: Redis or DynamoDB
  • Disks of a database: EBS

Neighbours

ProductAlikeDifferentChoose it for
Amazon EBSAWS storage, encryptionA disk for an instance, up to 64 TiB, low latency; some types attach to several instancesDatabases, boot disks
Amazon EFSGrows by itself, many readersNFS, POSIX permissions and locksShared files, older apps
Google Cloud StorageObjects, classes, strong consistencyBigQuery close by, other classesSystems on Google Cloud
Azure Blob StorageObjects, tiersMicrosoft identity and toolsSystems on Azure

What the bill is made of

ItemGrows withKeep it small by
StorageGB and class, old versions, unfinished uploadsLifecycle rules
RequestsPUT, LIST and GET countsLarger objects, fewer listings
RetrievalGB read from cold classesRight class
Transfer outGB to the internet or other regionsA CDN, computing in the same region

Strengths

  • Durability without work
  • No capacity planning
  • Classes and rules against cost
  • Strong consistency
  • Understood by nearly every tool

Costs

  • Roughly 100 to 200 ms for small objects
  • Objects replaced as a whole
  • One key at a time: no transactions
  • Not a file system
  • Transfer out is charged

Summary

The whole topic in one minute.

S3 is the place for whole files of any size: written once, read many times, kept safely. Keys are flat names, reads see the last completed write, and durability comes from spreading data over at least three zones and repairing it all the time.

Good designs let clients talk to it directly with presigned URLs, put a CDN in front, spread hot keys, use versions against mistakes and lifecycle rules against cost. Remember what it lacks: file locks, small edits and transactions over several objects.

  • Bucket, key, object: flat names over HTTP.
  • Eleven nines by design, three zones or more, strong consistency per key.
  • 3,500 writes or 11,000 reads a second per partitioned prefix, growing gradually.
  • Presigned URLs for clients, multipart for large files, a CDN for readers.
  • Versions against mistakes, lifecycle against cost, conditions against lost updates.

Sources