AWS Data Engineering
S3 Deep Dive: The Storage Layer Everything Else Builds On
DataForge AWS Data Engineering Series - Blog 2 of 20
The Athena bill arrived at $4,200 for the month. Nobody could explain it.
The data engineer pulled up the query history. Every query was scanning the entire dataset — 8TB of clickstream events stored as uncompressed CSV, no partitioning, one giant flat prefix with 40 million objects. A query asking for one day of data was scanning eight months of data to find it. At $5 per TB scanned, a query that should have cost $0.02 was costing $40.
Nobody had configured this deliberately. The pipeline had been writing raw CSV to S3 since day one because that’s what worked when the data volume was small. Nobody revisited the decision as volume grew 400×.
This is the S3 story that plays out at almost every data engineering team eventually. Not a service outage. Not a security breach. A storage decision made once, early, and never revisited — quietly costing thousands of dollars a month while looking completely normal in the AWS console.
S3 looks simple. Object storage. Put files in, get files out. The production reality is that S3’s cost model, consistency guarantees, and access patterns are the foundation every other AWS data service inherits — and getting them wrong compounds silently.
Let’s go deep.
TL;DR
S3 is not a hard drive with unlimited capacity. It’s an object store with a specific cost model (storage + requests + data transfer), specific consistency guarantees (strongly consistent since December 2020), and specific performance characteristics that depend entirely on how you organize your data. Every other AWS data service — Glue, Athena, EMR, Redshift — inherits S3’s behavior. Getting S3 architecture wrong at the beginning compounds into expensive, slow pipelines that look normal until someone checks the bill.
By the end of this article you’ll be able to:
- Choose the correct S3 storage class for any access pattern and calculate the real cost difference
- Explain why S3 request pricing, not storage pricing, is what kills budgets at scale
- Design partition and file layout strategies that cut Athena and Glue costs by 90%+
- Diagnose the small-file problem and apply the correct compaction strategy
Series context: Every subsequent blog in this series assumes the S3 patterns covered here. Blog 5 (Glue), Blog 12 (Athena), and Blog 6 (Redshift) all inherit whatever S3 layout decisions you make first.

What S3 Actually Is
S3 stores objects, not files. An object is a blob of data plus a key (the “path”) plus metadata. There is no real directory structure — the / characters in an S3 key are cosmetic. s3://bucket/raw/events/2024/01/15/file.parquet is one flat key, not five nested directories.
This distinction matters because it explains behavior that confuses engineers coming from filesystem backgrounds:
What looks like a directory listing:
aws s3 ls s3://bucket/raw/events/2024/01/15/
What's actually happening:
S3 performs a prefix scan — finding all keys that
start with "raw/events/2024/01/15/"
There is no directory inode to look up.
Every "directory listing" is a filtered scan.Why this matters: listing a prefix with 10 objects is fast. Listing a prefix with 10 million objects is slow — because S3 is scanning through key names, not looking up a directory entry. This is the root cause of the small-file problem covered later in this article.
The Cost Model: Three Line Items, Not One
Most engineers think of S3 cost as “storage cost.” S3 actually bills on three independent dimensions, and the one that surprises teams is almost never storage.
1. Storage cost
~$0.023/GB/month for S3 Standard
Scales linearly with data volume
2. Request cost
PUT/COPY/POST/LIST: ~$0.005 per 1,000 requests
GET/SELECT: ~$0.0004 per 1,000 requests
Scales with FILE COUNT and ACCESS PATTERN, not data volume
3. Data transfer cost
Transfer IN to S3: free
Transfer OUT to internet: ~$0.09/GB (first 10TB)
Transfer OUT to another AWS region: ~$0.02/GB
Transfer to same-region AWS service: free
The trap: storage cost is the easiest to estimate and the one everyone budgets for. Request cost is the one that blows budgets, because it depends on file count — a variable that data engineers don’t naturally think about when estimating cost.
The Small File Cost Calculation
Scenario: A streaming pipeline writes one file every 60 seconds
Files per day: 1,440
Files per year: 525,600
PUT request cost for one year of writes:
525,600 requests × $0.005 / 1,000 = $2.63
That looks cheap. Here's what it actually costs:
Every downstream read of this data requires:
- LIST operations to enumerate files in the prefix
- GET operations to read each file
A single Athena query scanning one month of this data:
43,800 files × GET request
= 43,800 × $0.0004/1,000 = $0.0175 per query
Run that query 500 times/month (dashboards, ad hoc analysis):
500 × $0.0175 = $8.75/month in GET requests alone
Now add: Glue crawler re-scanning the same prefix daily
30 runs/month × LIST cost on 525,600 objects
= significant, non-trivial LIST cost that compounds
The real cost isn't the storage. It's the operational tax
every downstream consumer pays for small files, forever,
on every read.
This is why file layout decisions made once at ingestion time echo through every downstream cost line item for the life of the dataset.
Storage Classes: Choosing Correctly
S3 offers seven storage classes, each with a different cost/retrieval trade-off. Data engineers typically need to know four of them well.
Class Storage cost/GB Retrieval Min duration
──────────────────────────────────────────────────────────────────────
S3 Standard $0.023 Instant None
S3 Standard-IA $0.0125 Instant 30 days
S3 Intelligent-Tiering $0.023 (+monitor) Instant None
S3 Glacier Instant $0.004 Instant 90 days
S3 Glacier Flexible $0.0036 1-5 min/hrs 90 days
S3 Glacier Deep Archive $0.00099 12+ hours 180 daysThe decision framework:
Access pattern Correct class
──────────────────────────────────────────────────────────
Bronze layer, accessed daily S3 Standard
Bronze layer, accessed weekly S3 Standard-IA
Silver/Gold, actively queried S3 Standard
Historical data, accessed monthly S3 Standard-IA
Compliance archive, rarely accessed S3 Glacier Instant
Regulatory retention, 7-year hold S3 Glacier Deep Archive
Unknown/unpredictable access pattern S3 Intelligent-TieringThe Standard-IA trap: Standard-IA has a minimum storage duration of 30 days and a per-GB retrieval fee (~$0.01/GB). If you transition data to Standard-IA and then access it frequently, you pay both the lower storage rate AND retrieval fees that can exceed what Standard would have cost. Standard-IA is correct for data accessed less than once per month — not as a default “cheaper storage” choice.
Lifecycle Policies: Automating the Transition
Manual storage class management doesn’t scale. Lifecycle policies automate transitions based on object age.
{
"Rules": [
{
"Id": "bronze-lifecycle",
"Status": "Enabled",
"Filter": {"Prefix": "raw/events/"},
"Transitions": [
{
"Days": 30,
"StorageClass": "STANDARD_IA"
},
{
"Days": 90,
"StorageClass": "GLACIER_IR"
},
{
"Days": 365,
"StorageClass": "DEEP_ARCHIVE"
}
]
}
]
}What this achieves: raw Bronze data written today is queried heavily in the first 30 days (active pipelines, backfills, debugging), then rarely touched. The lifecycle policy automatically moves it to progressively cheaper storage without any pipeline code changes. Most data lakes never configure this — the data sits in S3 Standard indefinitely, paying 5–20× more than necessary for data nobody is reading.
How S3 Consistency Actually Works
This is worth understanding precisely because architectures built before December 2020 often carry unnecessary complexity for a problem that no longer exists.
Before December 2020: S3 had eventual consistency for overwrite PUTs and DELETEs. You could write an object, immediately read it, and get the old version or a 404. This forced data engineers to build workarounds — checking for object existence with retry loops, using unique keys instead of overwrites, adding artificial delays before downstream reads.
Since December 2020: S3 is strongly consistent for all operations. A successful PUT is immediately visible to all subsequent GET, LIST, and HEAD requests. A successful DELETE immediately removes the object from all subsequent reads.
What this means practically:
Old pattern (unnecessary now):
write_object(key, data)
time.sleep(5) # "wait for eventual consistency"
read_object(key)
Current reality:
write_object(key, data)
read_object(key) # immediately consistent, no wait needed
Why this still matters for architecture review: you will encounter production pipelines with consistency workarounds built for a problem S3 solved years ago. Removing unnecessary sleep() calls and retry loops is free performance — but only if you understand that the underlying guarantee changed.
What strong consistency does NOT solve: if two processes write to the same key simultaneously, the last write wins — there’s no merge, no conflict detection. This is different from Delta Lake’s OCC (Part 1 of the Databricks series) which detects conflicting writes and retries. S3 itself has no transaction concept — that’s why Delta Lake, Iceberg, and Hudi exist as a layer on top of S3.
How File Layout Determines Query Cost: The Mechanism
This is the mechanism worth internalizing — because once you see how file organization changes what a query actually scans, every subsequent partitioning and format decision becomes obvious.
Walk through the same query against three different S3 layouts:
Query: "Total revenue for 2024-01-15"
Layout 1: Unpartitioned CSV, single flat prefix
s3://bucket/events/file1.csv
s3://bucket/events/file2.csv
... (40 million files, all dates mixed together)
Athena execution:
Scans ALL files — no way to know which contain Jan 15 data
Scans 8TB (entire dataset) to answer a query about 1 day
Cost: 8TB × $5/TB = $40 per query
Layout 2: Partitioned by date, still CSV
s3://bucket/events/year=2024/month=01/day=15/file1.csv
s3://bucket/events/year=2024/month=01/day=15/file2.csv
Athena execution:
Partition pruning: only scans year=2024/month=01/day=15/
Scans ~33GB (one day of the 8TB/240 days)
Still CSV — no column pruning, reads every column
Cost: 33GB × $5/TB = $0.165 per query
242x cheaper than Layout 1
Layout 3: Partitioned by date, Parquet (columnar)
s3://bucket/events/year=2024/month=01/day=15/file1.parquet
Athena execution:
Partition pruning: only scans day=15/ partition
Columnar format: only reads the "revenue" column,
not all 40 columns in the schema
Reads Parquet footer statistics to skip files that
don't contain matching data at all
Cost: ~2GB x $5/TB = $0.01 per query
4,000x cheaper than Layout 1The mechanism in one sentence: partitioning tells the query engine which files to skip entirely; columnar format tells it which parts of the remaining files to skip. Both are file-layout decisions made at write time, not query time — you cannot retrofit this optimization after the fact without rewriting the data.
Partitioning Strategy: Getting It Right
Partitioning is directory-like key prefixing that query engines use to skip irrelevant data. Choosing the right partition columns is the single highest-leverage S3 decision you’ll make.
Good partitioning candidates:
- Columns almost every query filters on (date is the classic case)
- Columns with moderate cardinality (10-10,000 distinct values)
- Columns known at write time
Bad partitioning candidates:
- High-cardinality columns (user_id with millions of values)
-> creates millions of tiny partitions, small-file problem
- Columns rarely used in WHERE clauses
-> partition pruning never triggers, no benefit
- Columns unknown until processing time
-> can't partition data that hasn't been computed yet
The partition explosion trap:
Partitioning by (year, month, day, hour, region, event_type):
365 days x 24 hours x 50 regions x 100 event types
= 43,800,000 possible partition combinationsEven with sparse data (not every combination has data),
this creates hundreds of thousands of tiny partition directories,
each with a handful of files.
Result: the "partition pruning" that was supposed to help
now requires listing hundreds of thousands of partition
prefixes to even determine which ones to scan.
The fix: partition by (year, month, day) only.
Let region and event_type be regular columns, filtered
via Parquet's columnar predicate pushdown instead of
partition pruning.
The practical rule: partition by 1–3 columns maximum, prioritizing the columns that appear in WHERE clauses across the most queries. Date-based partitioning (year/month/day) is correct for the vast majority of time-series data engineering workloads.
File Format: Why Parquet Wins for Analytics
CSV, JSON, Parquet, ORC, and Avro are the formats you’ll encounter. For analytical workloads (the majority of data engineering), the choice is not close.
Format Storage Query performance Schema evolution
----------------------------------------------------------------
CSV Row-based Slow (full scan) None (no schema)
JSON Row-based Slow (full scan) Flexible but slow
Avro Row-based Medium Strong (schema in file)
Parquet Columnar Fast (column skip) Good
ORC Columnar Fast (column skip) GoodWhy columnar formats win for analytics: a query selecting 3 columns out of 40 only needs to read those 3 columns’ data blocks. Row-based formats (CSV, JSON) must read every row in full, then discard the unwanted columns — you pay the I/O cost for data you don’t need.
Parquet vs ORC: functionally similar. Parquet has broader ecosystem support (Athena, Spark, Redshift Spectrum, virtually everything) and is the default recommendation. ORC has some Hive-specific optimizations but the ecosystem advantage goes to Parquet for AWS-native architectures.
When CSV/JSON are still correct: raw Bronze ingestion where source systems only produce these formats, and you plan to convert to Parquet in the Bronze-to-Silver transformation step. Never let CSV/JSON persist as your query-serving format at scale.
S3 Event Notifications: The Ingestion Trigger
S3 can emit events when objects are created, deleted, or restored. This is the mechanism that enables event-driven pipelines — processing starting when data arrives, not on a fixed schedule.
S3 Event -> destination options:
-> SQS queue (buffered, decoupled consumer)
-> SNS topic (fan-out to multiple consumers)
-> Lambda function (direct invocation)
-> EventBridge (routing to complex targets)
Common pattern:
S3 PutObject event
-> EventBridge rule matches prefix pattern
-> Triggers Step Functions execution
-> Step Functions starts Glue jobThe at-least-once delivery reality: S3 event notifications are delivered at-least-once, not exactly-once. Your downstream consumer (Lambda, Glue job triggered by the event) must be idempotent — processing the same event twice should produce the same result, not duplicate data. This is the same idempotency requirement covered in the Databricks series’ discussion of MERGE and stable business keys.
Architecture Flow: S3 as the Data Lake Foundation
Data Sources
|
v
+----------------------------------------------------+
| S3 BRONZE LAYER |
| s3://bucket/raw/{source}/{year}/{month}/{day}/ |
| Format: as received (JSON/CSV) or Parquet |
| Storage class: S3 Standard (recent), |
| lifecycle -> IA -> Glacier |
| Partition: date only (avoid explosion) |
+----------------------+-----------------------------+
| S3 event notification
v
EventBridge rule
|
v
Glue/EMR transformation
| writes
v
+-----------------------------------------------------+
| S3 SILVER LAYER |
| s3://bucket/silver/{table}/{year}/{month}/{day}/ |
| Format: Parquet (always) |
| File size target: 128MB-256MB after compression |
| Storage class: S3 Standard |
+----------------------+------------------------------+
|
+-----------+-----------+
v v
Athena (ad hoc) Redshift (warehouse)
scans S3 directly COPY loads from S3Failure Modes You’ll See in Production
The unpartitioned CSV data lake. The opening scenario. Data lands in S3 as CSV in a flat prefix structure. Query costs scale linearly with total data volume regardless of what’s actually needed. This is invisible until someone checks the Athena bill — the queries “work,” they’re just paying for far more scanning than necessary.
Small file accumulation from streaming writes. A Kinesis Firehose or streaming Glue job writes small files every few minutes without a compaction step. File count grows unbounded. LIST operations slow down, GET request costs accumulate, and eventually query latency becomes noticeably worse — but gradually enough that nobody identifies a specific “broke” moment.
Storage class misconfiguration causing retrieval fee surprises. An engineer sets an aggressive lifecycle policy transitioning data to Glacier Deep Archive after 7 days, not realizing a monthly reconciliation job needs to read 90-day-old data. Every reconciliation run now waits 12+ hours for Glacier retrieval and pays retrieval fees that exceed what Standard storage would have cost for that access pattern.
Partition explosion from over-partitioning. A well-intentioned engineer partitions by (year, month, day, hour, customer_id) to "make queries faster." With 50,000 customers, this creates millions of partition combinations. Glue crawlers take hours to catalog the partitions. Athena query planning time exceeds actual scan time. The fix requires rewriting the entire dataset with corrected partitioning.
Cross-region data transfer costs hidden in a different service’s bill. A Lambda function in us-east-1 reads from an S3 bucket in eu-west-1 for a compliance-driven data residency reason. Data transfer costs appear as a line item that doesn't obviously connect to "the S3 architecture decision made six months ago." Engineers debugging the Lambda cost don't think to check cross-region transfer.
Eventual consistency workarounds left in modern code. A codebase still contains time.sleep(5) calls and existence-check retry loops written for pre-2020 S3 consistency behavior. These don't cause correctness bugs anymore (S3 is strongly consistent now) but they add unnecessary latency to every pipeline run — accumulating to real time cost across thousands of daily executions.
Trade-offs: What S3 Optimizes For
S3 optimizes for:
- Durability (11 nines) and availability at massive scale
- Flexible access patterns — any service, any format, any access pattern
- Pay-for-what-you-use pricing with no upfront provisioning
- Infinite horizontal scale with no capacity planning required
S3 doesn’t optimize for:
- Query performance out of the box — that requires deliberate file organization
- Cost predictability — request costs scale with access patterns that are easy to misjudge
- Transactional guarantees — no ACID semantics without a layer like Delta Lake or Iceberg on top
- Low-latency single-object access at extreme request rates — S3 has per-prefix request rate limits that require key design awareness at very high throughput
The honest trade-off: S3 gives you effectively unlimited, durable, flexible storage. The cost of that flexibility is that nothing about performance or cost-efficiency is automatic — every optimization (partitioning, format, storage class, lifecycle) is a deliberate architectural decision you have to make, and the default behavior if you don’t make those decisions is expensive.
Real-World Constraints
S3 request rate limits. S3 supports 3,500 PUT/COPY/POST/DELETE and 5,500 GET/HEAD requests per second, per prefix. High-throughput workloads (thousands of Lambda functions writing simultaneously to the same prefix) can hit these limits. The fix is key design — distributing writes across prefixes rather than concentrating them, since the limit is per-prefix, not per-bucket.
Multipart upload thresholds. Objects larger than 5GB must use multipart upload. Most SDKs handle this automatically above a size threshold, but custom upload code that doesn’t account for this will fail silently or produce errors that look unrelated to file size. For data engineering, this becomes relevant when writing large compacted Parquet files or exporting large query results.
Cross-account and cross-region replication costs. S3 Cross-Region Replication (CRR) for disaster recovery or compliance duplicates storage costs and adds ongoing data transfer costs for every new object written. Teams that enable CRR “to be safe” without calculating the ongoing cost often discover it’s a significant, permanent addition to their AWS bill — not a one-time setup cost.
What This Means for the Rest of the Series
Every subsequent blog in this series builds on the S3 patterns from this article:
Blog 5 (Glue): reads Bronze S3, writes Silver S3 — the partition
and format choices here determine
Glue job runtime and cost
Blog 6 (Redshift): COPY command performance depends entirely
on S3 file count and size distribution
Blog 12 (Athena): query cost is a direct function of the
partitioning and format decisions in this article
Blog 13 (Medallion on AWS): the Bronze/Silver/Gold layers
are S3 prefixes with different
format and partition strategies
Get S3 layout right once, and every downstream service benefits automatically. Get it wrong, and every downstream service inherits the cost.
Summary: The Engineering Lesson
S3 is not a hard drive. It’s a request-priced, format-agnostic object store where the actual cost and performance of your data platform is determined almost entirely by decisions made at write time — partition strategy, file format, file size, storage class — not by anything you configure in the query engine later.
The $4,200 Athena bill from the opening scenario wasn’t a service problem. Athena did exactly what it was asked to do — scan the data needed to answer the query. The problem was that “the data needed to answer the query” was 8TB instead of 2GB, because nobody made a partitioning and format decision when the pipeline was built.
Every dollar S3 costs downstream was determined the day the first file was written.
Get that decision right, and the entire stack built on top of it — Glue, Athena, Redshift, EMR — inherits efficiency for free. Get it wrong, and every service built on top inherits the cost, silently, until someone checks the bill.
Next in Series
Blog 3 - IAM for Data Engineers: Security Without Breaking Everything
S3 is where your data lives. IAM is what determines who can touch it — and IAM misconfigurations are the single most common reason data pipelines fail in production, not because of bad code but because a Glue job or Lambda function was never granted the right permission in the first place.
We’ll go deep on the specific IAM patterns data pipelines need — service roles, trust policies, resource-based policies, cross-account access — and the failure modes that produce “access denied” errors that look like everything except what they actually are.
Comment Below
What’s the most expensive S3 layout mistake you’ve seen or made?
Was it unpartitioned CSV that turned every Athena query into a full-table scan? A streaming pipeline that accumulated millions of small files before anyone noticed LIST operations had gotten slow? A lifecycle policy that moved active data to Glacier and turned a routine job into a 12-hour wait?
And — did you find it from the bill, from a slow query complaint, or from someone who’d made the same mistake before and knew what to look for?
Tags: aws-data-engineering, amazon-s3, data-lake, parquet, partitioning, storage-classes, athena-cost-optimization, aws-glue, dataforge