S3 storage classes, lifecycle, versioning & replication
Design a cost-effective, durable S3 strategy for a given access pattern.
By Invicly Tech, , in AWS Solutions Architect – Associate. About 13 minutes to read.
In short
S3 stores objects in buckets with eleven nines of durability. Storage classes trade retrieval speed and fees for lower storage price, and lifecycle rules move or expire objects automatically. Versioning protects against deletes and is required for replication.
Explained simply
Amazon S3 (Simple Storage Service) stores files, which AWS calls objects, inside containers called buckets. Each object has a key (its full name, like photos/2026/cat.jpg), the data itself, and some metadata. There are no real folders: the slashes are just part of the key, and the console draws folders to help you.
S3 is built to keep data safe. Most storage classes keep copies in several Availability Zones (separate data centers), and S3 is designed for 99.999999999 percent durability, often called eleven nines. If you store 10 million objects, you would expect to lose one about once every 10,000 years.
Not all data is read equally. New uploads are read often, old logs almost never. S3 offers storage classes: the cheaper ones charge less per GB to store, but add a fee per GB to read, a minimum storage time, or a wait before you can read. Lifecycle rules move objects between classes automatically as they get older.
Two features protect you from mistakes. Versioning keeps every old version of an object, so an overwrite or a delete can be undone. Replication copies objects to another bucket, in the same Region or a different one, for backup, compliance, or lower latency for users far away.
Press Play on a diagram to walk through it one step at a time.
- Standard: default, multi-AZ
- Intelligent-Tiering: unknown patterns
- Express One Zone: lowest latency
- Standard-IA: 30-day minimum
- One Zone-IA: one AZ, recreatable data
- Retrieval fee per GB
- Glacier Instant: milliseconds, 90 days
- Glacier Flexible: minutes to hours
- Deep Archive: 12 to 48 hours
- Deep Archive is cheapest
- 1Day 0: Standard
New uploads are read often.
- 2Day 30: Standard-IA
Reads drop but must stay instant.
- 3Day 90: Glacier Flexible
Kept for audits, hours to restore.
- 4Day 365: Deep Archive
Long-term compliance retention.
- 5Year 7: Expire
Delete when retention ends.
- Often, or pattern unknown
- S3 Standard
- Intelligent-Tiering if it changes over time
- About monthly, must be instant
- Standard-IA
- One Zone-IA if you can recreate it
- Quarterly or less, must be instant
- Glacier Instant Retrieval
- Rarely, can wait hours
- Glacier Flexible Retrieval
- Deep Archive if 12 to 48 hours is fine
- Very hot, next to compute
- S3 Express One Zone
- Single-digit millisecond reads in one AZ
- App to Source bucket: PUT report.csv1PUT report.csv
- Source bucket to App: 200 OK, version v12200 OK, version v1
- Source bucket to Destination bucket: Async copy using the IAM role3Async copy using the IAM role
- 4Stored with status REPLICADestination bucket to Destination bucket: Stored with status REPLICA
- App to Source bucket: DELETE report.csv (no version ID)5DELETE report.csv (no version ID)
- Source bucket to Destination bucket: Delete marker copied only if enabled6Delete marker copied only if enabled
In depth
Choosing a class: the hidden charges
The price per GB is only part of the bill. Standard-IA and One Zone-IA charge for at least 30 days of storage and at least 128 KB per object, plus a retrieval fee per GB read. Glacier Instant Retrieval and Glacier Flexible Retrieval have a 90-day minimum, and Deep Archive has 180 days. If you delete or move an object early, you still pay for the remaining days.
So the IA classes suit objects that are fairly large, kept for months, and read rarely. Millions of tiny files that live for a week are cheaper in Standard. Intelligent-Tiering has no retrieval fees. Instead it charges a small monthly monitoring fee per object and moves objects to cheaper tiers after 30 and 90 days without access. Objects under 128 KB are never moved and pay no monitoring fee, so they always stay in the frequent tier.
- Standard-IA and One Zone-IA: 30-day minimum, 128 KB minimum billable size
- Glacier Instant and Glacier Flexible: 90-day minimum
- Deep Archive: 180-day minimum
- Intelligent-Tiering: no retrieval fee, small per-object monitoring fee
Getting data back from the Glacier classes
Glacier Instant Retrieval returns data in milliseconds, like Standard-IA, but each read costs more. The other two archive classes need a restore first. You call RestoreObject (aws s3api restore-object) with a number of days and a speed. S3 then creates a temporary readable copy, and you read that copy until the days run out. The archived object itself stays where it is.
Glacier Flexible Retrieval offers three speeds: Expedited in 1 to 5 minutes, Standard in 3 to 5 hours, and Bulk in 5 to 12 hours, which is free. Deep Archive offers Standard within 12 hours and Bulk within 48 hours. Exam questions often hide the answer in how long the business can wait.
- Your app to Amazon S3: restore-object: Days 7, Tier Standard1restore-object: Days 7, Tier Standard
- Amazon S3 to Your app: 202 Accepted, restore in progress2202 Accepted, restore in progress
- Your app to Amazon S3: HEAD object: still restoring?3HEAD object: still restoring?
- 43 to 5 hours later: temporary copy readyAmazon S3 to Amazon S3: 3 to 5 hours later: temporary copy ready
- Your app to Amazon S3: GET object reads the temporary copy5GET object reads the temporary copy
- 6After 7 days the temporary copy is removedAmazon S3 to Amazon S3: After 7 days the temporary copy is removed
Versioning and delete markers
Once versioning is on, every upload of the same key creates a new version with its own version ID. A plain DELETE does not remove any data: S3 puts a delete marker on top, and the object looks gone. Remove that marker, or GET an older version ID, and the data is back. Only a DELETE that names a specific version ID removes that version for good.
A bucket can be unversioned, enabled or suspended, but it can never go back to unversioned. Old versions are billed like any other data, so add a lifecycle rule with NoncurrentVersionExpiration, for example to keep old versions for 30 days. MFA delete adds a second check: deleting a version or changing the versioning state needs a code from an MFA device. Only the root user can turn it on, and only with the CLI or API, not the console.
- 1PUT report.csv
Version v1 is current
- 2PUT report.csv again
v2 is current, v1 is kept
- 3DELETE report.csv
A delete marker becomes current
- 4GET report.csv
Returns 404, but v1 and v2 still exist
- 5Delete the marker
v2 is current again
How replication really behaves
Replication needs versioning on both buckets and an IAM role that S3 uses to copy objects. Rules can filter by prefix or tag, choose a cheaper storage class at the destination, and hand ownership to the destination account. Same-Region Replication (SRR) suits log collection or a separate test copy. Cross-Region Replication (CRR) suits disaster recovery, compliance and users in another Region.
Some things are not copied by default. Objects that existed before the rule need S3 Batch Replication. Delete markers are copied only if you turn on delete marker replication, and deleting a specific version is never replicated, which protects the copy from a malicious delete. Replication is asynchronous and most objects arrive within minutes. S3 Replication Time Control (RTC) adds an SLA: 99.99 percent of new objects replicate within 15 minutes.
- Needs versioning on source and destination
- Existing objects: use S3 Batch Replication
- Replicas are not replicated again by default (no chaining)
- SSE-KMS objects need the KMS key settings in the rule
Performance at scale
S3 scales per prefix (the part of the key before the object name, such as logs/2026/). Each prefix supports at least 3,500 PUT, COPY, POST or DELETE requests and 5,500 GET or HEAD requests per second, and there is no limit on the number of prefixes. Spread keys over 10 prefixes and you get roughly 10 times the request rate.
For big files, multipart upload splits an object into parts of 5 MiB to 5 GiB (up to 10,000 parts) that upload in parallel and retry on their own. One single PUT can be at most 5 GB, so larger objects must use multipart; the AWS CLI does this automatically. Byte-range GETs do the same for downloads. Transfer Acceleration sends uploads through CloudFront edge locations, which helps users far from the bucket. Since 2020 S3 is strongly consistent: a read after a successful write always sees the new data.
Learn it in 5 short steps
About 1h each. Track them with a timer in your plan.
- 1Compare S3 storage classes~1h
- 2Write lifecycle rules to tier and expire data~1h
- 3Enable versioning and MFA delete~1h
- 4Set up cross-Region replication~1h
- 5Design storage for a given access pattern~1h
Key points
- Use Intelligent-Tiering when access patterns are unknown or change.
- Same-Region and cross-Region replication both require versioning on source and destination.
- MFA delete and Object Lock protect against accidental or malicious deletion.
- Replication copies new objects; use Batch Replication for existing ones.
- Use multipart upload for large objects, recommended above 100 MB.
Key terms
Tap a card to flip it. 0/5 known
Examples
{"Rules": [{
"ID": "tier-logs",
"Filter": {"Prefix": "logs/"},
"Status": "Enabled",
"Transitions": [
{"Days": 30, "StorageClass": "STANDARD_IA"},
{"Days": 90, "StorageClass": "GLACIER"}
],
"Expiration": {"Days": 2555}
}]}Lifecycle config for aws s3api put-bucket-lifecycle-configuration.
Undo an accidental delete
A teammate deleted reports/q3.csv from a versioned bucket. Nothing is lost yet: S3 only added a delete marker. Step 1: list the versions and delete markers for that key. Step 2: find the delete marker that is marked IsLatest and copy its VersionId. Step 3: delete the marker itself by naming its version ID. The newest real version becomes current again, with no copy or restore needed.
# 1. See all versions and delete markers for the key
aws s3api list-object-versions --bucket my-bucket --prefix reports/q3.csv \
--query '{versions: Versions[].[VersionId,IsLatest], markers: DeleteMarkers[].[VersionId,IsLatest]}'
# 2. Remove the delete marker (use the marker's VersionId)
aws s3api delete-object --bucket my-bucket --key reports/q3.csv \
--version-id MARKER_VERSION_ID
# 3. The previous version is current again
aws s3api head-object --bucket my-bucket --key reports/q3.csvStorage design for a photo app
Users view new photos a lot in the first month, rarely afterwards, but any photo must open instantly. Thumbnails are small (about 30 KB) and can be regenerated. Step 1: keep originals in Standard for 30 days, then move them to Standard-IA, then to Glacier Instant Retrieval at 90 days, which still reads in milliseconds. Step 2: leave thumbnails in Standard, because IA would bill each one as 128 KB. Step 3: enable versioning, and expire old versions after 30 days so overwrites don't pile up cost.
{"Rules": [{
"ID": "originals-tiering",
"Filter": {"Prefix": "originals/"},
"Status": "Enabled",
"Transitions": [
{"Days": 30, "StorageClass": "STANDARD_IA"},
{"Days": 90, "StorageClass": "GLACIER_IR"}
],
"NoncurrentVersionExpiration": {"NoncurrentDays": 30}
}]}Quick reference
- aws s3api put-bucket-versioning --bucket b --versioning-configuration Status=Enabled
- Minimum storage days: IA classes 30, Glacier Instant and Flexible 90, Deep Archive 180
- IA and Glacier Instant bill at least 128 KB per object; keep tiny files in Standard
- Glacier Flexible restore: Expedited 1-5 min, Standard 3-5 h, Bulk 5-12 h (free)
- Deep Archive restore: Standard within 12 h, Bulk within 48 h
- Per prefix: 3,500 writes and 5,500 reads per second; add prefixes to scale
- Single PUT max 5 GB; use multipart upload for large files (the CLI does it for you)
- Replication skips objects that existed before the rule; use S3 Batch Replication
Common mistakes
- Moving tiny or short-lived objects to IA classes and paying minimum size and duration charges.
- Choosing One Zone-IA for data that cannot be recreated.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Create a bucket, enable versioning, upload the same file twice with different content, then list its versions.
- Exercise 2medium
Add a lifecycle rule to your bucket that deletes old versions 30 days after they become noncurrent but always keeps the 3 newest old versions, and cleans up unfinished multipart uploads after 7 days.
- Exercise 3hard
Set up Cross-Region Replication from a bucket in us-east-1 to a bucket in eu-west-1, including delete markers, and prove that a new object arrives.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Does S3 have folders?
- No. S3 keeps a flat list of keys. The console shows folders by splitting keys on the slash, and the API can do the same with a prefix and a delimiter.
- What is the difference between durability and availability in S3?
- Durability is the chance your data is not lost, eleven nines for S3 classes. Availability is the chance you can read it right now, for example designed for 99.99 percent in Standard and 99.5 percent in One Zone-IA.
- Does versioning cost extra?
- The feature itself is free, but every old version is billed as stored data. Use lifecycle rules to expire noncurrent versions you no longer need.
- Is S3 Glacier a separate service?
- There used to be a separate Glacier service with its own vaults. Today you normally use the Glacier storage classes inside ordinary S3 buckets, chosen at upload or by a lifecycle rule.