The one-line mental model
S3 is a flat key-value object store that only pretends to be a filesystem, and nearly every cost, performance and durability decision in a data lake comes from understanding how prefixes, storage classes and request patterns interact.
After this lesson you will be able to size a storage bill before you build, write a lifecycle rule that does not strand data, choose an encryption mode that satisfies an auditor, and explain why a lake with millions of tiny files queries slowly no matter how many bytes it holds.
Prerequisites
- !Basic AWS vocabulary: accounts, regions, IAM and the shared responsibility model
- !Comfort with columnar file formats such as Parquet
What You'll Learn
- 1Map access patterns to storage classes and retrieval costs
- 2Author lifecycle transitions and expiration rules deliberately
- 3Compare SSE-S3, SSE-KMS and SSE-C on control and audit needs
- 4Tune prefixes, multipart uploads and file sizes for throughput
Buckets, keys and why flat beats deep
An S3 bucket holds objects, each addressed by a key such as raw/orders/dt=2026-03-01/part-0000.parquet. There are no real directories, only slashes inside keys, which means the layout you choose is a convention you impose rather than a constraint S3 enforces. That freedom matters because S3 scales horizontally by spreading requests across prefixes: a single hot prefix can throttle while five hundred evenly used prefixes absorb the same load comfortably.
Three numbers are worth memorising for interviews and for capacity planning. Objects scale to five terabytes each, with single PUT requests capped at five gigabytes and everything larger uploaded in parts. Durability is eleven nines of annual probability of loss, achieved by replicating each object across multiple devices in at least three availability zones for Standard. Availability varies by class, from 99.99% for Standard down to 99.5% for One Zone-IA, which stores a single copy in one zone and is therefore only appropriate for data you can recreate.
The practical consequence for data engineers is that your prefix design is your throughput design. Hive-style partitioning such as year=2026/month=03/day=01 gives analytics engines the ability to skip entire partitions, while spreading ingestion across a handful of well-chosen sub-prefixes keeps any one path from becoming a bottleneck during heavy parallel writes.
Choosing a storage class by access pattern, not by price
The cheapest per-gigabyte rate is rarely the cheapest bill, because every class carries a different retrieval and minimum-duration charge. Choose by what you actually read and how fast you need it back.
| Storage class | Availability | Minimum duration | Retrieval speed | Typical monthly rate | Use it for |
|---|---|---|---|---|---|
| S3 Standard | 99.99% | None | Milliseconds | Around $0.023/GB | Hot fact tables and active staging |
| Intelligent-Tiering | 99.9% | None, small monitoring fee | Milliseconds | Tier dependent | Unknown or erratic access patterns |
| Standard-IA | 99.9% | 30 days | Milliseconds | Around $0.0125/GB | Monthly-close and audit archives |
| One Zone-IA | 99.5% | 30 days | Milliseconds | Around $0.01/GB | Reproducible intermediates |
| Glacier Instant Retrieval | 99.9% | 90 days | Milliseconds | Around $0.004/GB | Quarterly archives read rarely |
| Glacier Flexible Retrieval | 99.99% | 90 days | Minutes to hours | Around $0.0036/GB | Compliance archives, occasional pulls |
| Glacier Deep Archive | 99.99% | 180 days | 12 to 48 hours | Under $0.001/GB | Seven-year retention, restore rarely |
Intelligent-Tiering is the answer when nobody can predict access: it watches each object for thirty days and moves it between automatic tiers, charging a small per-gigabyte monitoring fee instead of imposing retrieval penalties. It is not a substitute for lifecycle rules on data you know is cold, because the frequent-access tier still costs Standard rates until the observation window closes.
Always model retrieval, not just storage. A Glacier Flexible restore that must finish within an hour costs meaningfully more than a patient one, and a surprise bill from an unplanned bulk restore during an incident is a rite of passage worth avoiding by testing your archive policy once a year.
Lifecycle rules that earn their keep
Lifecycle configuration is JSON attached to a bucket that automates transitions and expiration. The rule below encodes a realistic data lake policy: hot for a quarter, infrequent for half a year, archive for two years, and a hard stop afterwards.
{
"Rules": [
{
"ID": "raw-zone-lifecycle",
"Status": "Enabled",
"Filter": { "Prefix": "raw/" },
"Transitions": [
{ "Days": 90, "StorageClass": "STANDARD_IA" },
{ "Days": 180, "StorageClass": "GLACIER" },
{ "Days": 730, "StorageClass": "DEEP_ARCHIVE" }
],
"Expiration": { "Days": 2555 }
},
{
"ID": "abort-incomplete-multipart",
"Status": "Enabled",
"Filter": {},
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
}
]
}
The second rule is the one most teams discover only after a bill: interrupted multipart uploads leave parts in the bucket indefinitely, each billed at Standard rates, and without an abort rule they accumulate forever. Transitions evaluate once a day and execute asynchronously, so expect up to a day of lag, and remember that objects must reach the minimum age of their target class or the transition is rejected. Expiration deletes objects and, with versioning enabled, expires non-current versions as well, which is how you keep the storage savings of versioning from erasing the benefit of your lifecycle policy.
Encryption options and which one an auditor accepts
Server-side encryption means S3 encrypts data at rest with an AES-256 key and decrypts it transparently on read. The four options differ in who controls the key and whether usage leaves an audit trail.
| Method | Key control | Audit trail via CloudTrail | Cost | When to choose it |
|---|---|---|---|---|
| SSE-S3 | AWS manages entirely | No | Free | Internal data with no compliance driver |
| SSE-KMS | Customer-managed key in KMS | Yes, every decrypt logged | Key and API charges | Regulated data and any PII |
| SSE-C | Caller supplies the key per request | No | Free | Legacy systems that already hold keys |
| Client-side | You encrypt before upload | Depends on your tooling | Free | Maximum control, full complexity |
SSE-KMS with a bucket key enabled is the default recommendation for a data platform. The bucket key drastically reduces KMS request charges by wrapping one data key for many objects, while every use of the underlying key still lands in CloudTrail, which is exactly the evidence an auditor asks for. Enforce encryption at rest as a bucket policy condition as well as a default encryption setting, so an object written with an explicit weaker header is rejected rather than silently stored.
{
"Rules": [
{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "aws:kms",
"KMSMasterKeyID": "arn:aws:kms:us-east-1:123456789012:key/1234abcd-key"
},
"BucketKeyEnabled": true
}
]
}
Throughput: prefixes, multipart and file size
Raw bandwidth is rarely the limit in a data lake; request overhead and file size are. S3 scales to at least thirty-five hundred PUT, COPY, POST or DELETE requests per second per prefix and one hundred GET requests per second, so the usual fix for slow ingestion is spreading writes across prefixes rather than buying a bigger instance.
import boto3
from boto3.s3.transfer import TransferConfig
s3 = boto3.client("s3")
config = TransferConfig(
multipart_threshold=100 * 1024 * 1024,
multipart_chunksize=100 * 1024 * 1024,
max_concurrency=10,
use_threads=True,
)
s3.upload_file(
"orders-2026-03.parquet",
"acme-data-lake",
"raw/orders/dt=2026-03-01/orders-2026-03.parquet",
Config=config,
)
paginator = s3.get_paginator("list_objects_v2")
small = 0
for page in paginator.paginate(Bucket="acme-data-lake", Prefix="raw/orders/"):
for obj in page.get("Contents", []):
if obj["Size"] < 128 * 1024 * 1024:
small += 1
print(f"{small} files below 128 MB should be compacted")
Multipart upload matters twice: it enables parallel transfer of large objects, and it allows an incomplete upload to be resumed or aborted. Below the hundred-megabyte threshold the overhead of coordination outweighs the benefit. On the read side, the sweet spot for columnar files is roughly two hundred and fifty megabytes to one gigabyte per object, which gives engines enough parallelism to distribute work while keeping the per-object open and planning cost small. Files under a few megabytes are the classic hidden tax: Athena charges per data scanned and per file handled, so a partition containing ten thousand tiny files costs far more to query than one file of the same total size.
A bucket layout that survives real workloads
Structure the lake by trust level rather than by source system, because the transformation stage determines who may read the data and how long it must be kept.
s3://acme-data-lake/
โโโ raw/ # immutable landing zone, partitioned by date
โ โโโ orders/dt=2026-03-01/
โโโ processed/ # cleansed, deduplicated, typed
โ โโโ orders/dt=2026-03-01/
โโโ curated/ # modelled tables registered in Glue
โ โโโ dim_customer/
โ โโโ fact_order/
โโโ aggregate/ # pre-computed marts for dashboards
โโโ archive/ # Glacier target for expired raw data
โโโ _checkpoints/ # streaming offsets and job state
โโโ _quarantine/ # records rejected by quality gates
Raw stays write-once so a replay can always reproduce history. Processed is where cleaning happens and is safe to overwrite by partition. Curated tables are the contract with consumers and should be registered in the Glue Data Catalog with statistics refreshed, because Athena's optimiser depends on them. The quarantine path is underrated: routing bad records aside instead of failing the whole load keeps ingestion alive while giving data quality something concrete to alert on.
The security baseline before you go live
Turn on Block Public Access at the account level as well as per bucket, so a single mis-scoped policy cannot expose the lake. Require TLS with a bucket policy condition denying non-HTTPS requests. Enable server access logging and CloudTrail data events for the buckets that hold regulated data, and ship both to a separate account so an attacker in the data account cannot erase evidence. Enable versioning when you need recovery from overwrite or delete, and pair it with Object Lock in compliance mode if a regulation demands write-once retention. For cross-account analytics, prefer bucket policies scoped to named roles over ACLs, and reach for Lake Formation when access must be granted at the table or column level rather than the whole prefix. Finally, use pre-signed URLs for time-boxed sharing instead of making objects public, and review them like you would review a password.
Common Mistakes
Leaving every object in S3 Standard forever
Fix: Attach lifecycle transitions so cold prefixes age into IA and Glacier automatically
Ignoring incomplete multipart uploads
Fix: Add an abort rule after seven days so abandoned uploads stop billing
Ingesting thousands of small files per partition
Fix: Batch or compact writes to 256 MB or larger objects before publication
Relying on default encryption with no audit trail
Fix: Use SSE-KMS with a bucket key and deny unencrypted or non-TLS writes in bucket policy
Best Practices
- Design prefixes for both partition pruning and request distribution
- Enable versioning, lifecycle rules and Block Public Access on every new bucket
- Model total cost including requests, retrieval and data transfer, not just per-GB rates
- Register curated paths in the Glue catalog and keep table statistics current
- Test an archive restore from Glacier on a schedule so the recovery time is known
Interview Questions
Q1: S3 Standard or Intelligent-Tiering for a table with unpredictable access?
Intelligent-Tiering, because it reclassifies objects after thirty days of observation with no retrieval fees, whereas Standard-IA would incur minimum-duration and retrieval charges on surprise reads.
Q2: How do lifecycle policies interact with versioning?
They can expire non-current versions and abort incomplete uploads, which is how you keep versioning enabled without letting old versions dominate the bill.
Q3: Why does a data lake with lots of small files query slowly?
Analytics engines pay per object and per byte scanned, so file-open overhead dominates and parallelism is wasted on coordination rather than data.
Q4: What does a bucket key do?
It wraps a single KMS data key for many objects in the bucket, cutting KMS API charges dramatically while preserving per-request audit logging of the underlying key.
Key Takeaways
- S3 is flat: prefix design determines both query pruning and request throughput
- Choose storage classes by access pattern and retrieval SLA, then automate movement with lifecycle rules
- Always abort incomplete multipart uploads and budget for requests as well as gigabytes
- SSE-KMS with a bucket key gives compliance evidence without prohibitive cost
- Small files are a query tax; compact to the 256 MB to 1 GB range before publishing tables