AWS Data Engineering
AWS Data Engineering Cost Optimization - A Practical Audit
Here Is a Systematic Audit of Your AWS Data Engineering Costs With Specific Changes That Reduce Bills by 30-50 Percent.

TL;DR
- S3 storage class defaults to Standard for everything — most data engineering datasets have an access pattern that makes Standard the wrong choice within 30–60 days
- Glue jobs are provisioned by guesswork more often than by measurement — DPU counts get set once at creation and never revisited as data volume and job characteristics change
- Athena bills per byte scanned, not per query — the same query against unpartitioned CSV and partitioned Parquet can differ in cost by more than 10x for identical logical output
- Lambda’s per-invocation memory setting controls both memory and proportional CPU — over-provisioning memory to “be safe” is a direct, linear cost increase
- None of these fixes require new tooling — they are configuration and layout changes to infrastructure that’s already running
The AWS bill doesn’t lie about waste. It just doesn’t organize the waste by cause, so nobody looks until someone is asked to explain a number.
The monthly AWS bill for the data platform had crept from $6,000 to $10,600 over eight months. Nobody had made a deliberate decision to spend more — the platform team had just kept shipping pipelines, and the bill kept climbing in the background of a dozen other priorities.
A CFO question — “why did this line item double?” — forced an actual audit for the first time in the platform’s life.
The answer, once someone actually looked: eleven months of raw ingestion data sitting in S3 Standard that hadn’t been queried since day three. A Glue job provisioned with 20 DPUs for a dataset that had shrunk to a tenth of its original size after an upstream change, still running at the original allocation. An Athena dashboard query scanning full unpartitioned CSV files every time a stakeholder refreshed a page.
None of it was a bug. All of it was a default nobody had gone back to check.
The Bill Nobody Had Looked At Line by Line
Cloud cost creep in data platforms rarely comes from one dramatic mistake. It comes from a series of reasonable-at-the-time decisions — Standard storage because that was the default, a DPU count picked once and never revisited, an unpartitioned table because partitioning felt like premature optimization at the time — compounding quietly while the bill is reviewed as a single number rather than as a sum of specific, auditable line items.
This post is the audit. Four cost centers, the specific waste pattern each one produces, and the fix for each.
S3 Storage Classes and When to Use Each
The Default-Everything-Standard Problem
Every object written to S3 without an explicit storage class lands in Standard — the most expensive tier, designed for data accessed frequently. Most data engineering datasets do not have a frequent-access pattern past their first few weeks of life.
S3 Standard: ~$0.023/GB/month — frequent access
S3 Standard-IA: ~$0.0125/GB/month — infrequent access,
retrieval fee applies
S3 Intelligent-Tiering: automatically moves objects between tiers based on
observed access patterns, no retrieval fee for the
frequent/infrequent tiers
S3 Glacier Instant: ~$0.004/GB/month — archival with
millisecond retrieval
S3 Glacier Deep Archive: ~$0.00099/GB/month — archival, retrieval takes hoursA raw ingestion bucket that is queried heavily in its first week and essentially never again is a textbook case for either an explicit lifecycle transition or Intelligent-Tiering — and the cost difference between leaving it in Standard indefinitely and transitioning it is not marginal.
Lifecycle Policies That Actually Match Access Patterns
{
"Rules": [
{
"ID": "raw-ingestion-lifecycle",
"Filter": { "Prefix": "raw/ingestion/" },
"Status": "Enabled",
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER_IR" },
{ "Days": 365, "StorageClass": "DEEP_ARCHIVE" }
]
},
{
"ID": "curated-tables-intelligent-tiering",
"Filter": { "Prefix": "curated/" },
"Status": "Enabled",
"Transitions": [
{ "Days": 0, "StorageClass": "INTELLIGENT_TIERING" }
]
}
]
}Raw, rarely-requeried data gets an explicit lifecycle — the access pattern is predictable enough (heavy early, then essentially archival) that a fixed schedule works. Curated tables with less predictable access patterns are better served by Intelligent-Tiering, which adapts automatically rather than requiring someone to have correctly guessed the access pattern in advance.
For the eleven months of raw ingestion data in the opening story, applying a lifecycle policy retroactively — a one-time aws s3 cp with the target storage class, or a batch operation for large volumes — captured the bulk of the storage savings in that audit without touching a single pipeline.
Glue Job Cost Reduction Techniques
DPU Overprovisioning
AWS Glue bills per DPU-hour. A job provisioned with 20 DPUs runs 20 DPUs’ worth of compute whether or not the data volume still justifies it — and DPU counts are set once, at job creation, based on whatever data volume existed at the time.
# Check actual DPU utilization from Glue job run metrics
# via CloudWatch — the metric to look at is
# glue.driver.aggregate.numCompletedTasks vs the allocated
# worker count, and whether the job is bottlenecked on
# shuffle/IO (needs the DPUs) or was simply over-allocated
import boto3
def get_glue_job_metrics(job_name: str, run_id: str):
client = boto3.client("glue")
run = client.get_job_run(JobName=job_name, RunId=run_id)
execution_time = run["JobRun"]["ExecutionTime"] # seconds
dpu_seconds = run["JobRun"].get("DPUSeconds", 0)
allocated_capacity = run["JobRun"].get("MaxCapacity", 0)
print(f"Job: {job_name}")
print(f"Execution time: {execution_time}s")
print(f"Allocated DPUs: {allocated_capacity}")
print(f"Actual DPU-seconds billed: {dpu_seconds}")
# If execution time is short and allocated capacity is high,
# the job likely completed well within its allocated resources —
# a signal to right-size downwardThe fix in the opening story’s Glue job — reducing from 20 DPUs to a capacity matching the dataset’s current, shrunk size — required no code change, only revisiting a number that had been set eight months earlier against a dataset ten times larger.
# Glue also supports auto-scaling for compatible job types —
# removes the need to guess a fixed DPU count at all
glue_job_config = {
"Name": "daily-transactions-etl",
"GlueVersion": "4.0",
"WorkerType": "G.1X",
"NumberOfWorkers": 10, # upper bound
"ExecutionProperty": {"MaxConcurrentRuns": 1},
# Auto-scaling adjusts actual worker count within this bound
# based on the job's real resource needs per run
}Job Bookmarks and Reprocessing Waste
A Glue job without bookmarks enabled reprocesses the entire source dataset on every run — including data already processed in prior runs. This is a common and expensive default oversight, particularly for jobs that read from S3 sources that grow over time.
# Enable job bookmarks — Glue tracks what's already been processed
# and only picks up new data on subsequent runs
job.init(args["JOB_NAME"], args)
datasource = glueContext.create_dynamic_frame.from_catalog(
database="raw_data",
table_name="transactions",
transformation_ctx="datasource", # required for bookmarks to function
)The transformation_ctx parameter is what makes bookmarking work — without it, even a job with bookmarks nominally enabled at the job level will still reprocess everything. This is a common silent misconfiguration: bookmarks appear enabled in the job settings while every run still scans the full source.
Athena Query Optimization for Cost
Athena Bills Per Byte Scanned, Not Per Query
Athena’s pricing model — cost proportional to data scanned, not to query complexity or runtime — makes storage format and partitioning the two highest-leverage cost levers available, more impactful than any query rewriting.
Same logical query, different physical layout:
Unpartitioned CSV, 500 GB total:
SELECT * FROM transactions WHERE transaction_date = '2026-05-01'
→ scans all 500 GB, no partition pruning possible on CSV,
no column pruning possible on row-oriented format
→ cost: 500 GB scanned
Partitioned Parquet by date, same logical data:
Same query
→ scans only the '2026-05-01' partition (say, 1.8 GB)
→ columnar format means only queried columns are read,
further reducing scanned bytes
→ cost: a small fraction of the unpartitioned CSV cost,
for identical query logic and identical result
Partitioning and Columnar Format as Cost Levers
# Converting a dashboard's source table from unpartitioned CSV
# to partitioned Parquet — a one-time Glue or Spark job
df = spark.read.option("header", "true").csv("s3://bucket/raw/transactions/")
df.write \
.partitionBy("transaction_date") \
.option("compression", "snappy") \
.parquet("s3://bucket/curated/transactions_parquet/")
# Update the Glue Data Catalog / Athena table definition
# to point at the new partitioned Parquet locationThe Athena cost line in the opening story’s audit — a dashboard query scanning full CSV files on every stakeholder refresh — was resolved entirely by this conversion, with no change to the dashboard’s query logic or the SQL a stakeholder was running. The query stayed the same. The bytes it had to scan to answer that query dropped by an order of magnitude.
For workloads where the underlying source must remain CSV or JSON for compatibility reasons, a Glue crawler-maintained Parquet copy specifically for Athena querying is a reasonable middle ground — dual storage, but the Athena-facing copy is optimized for the cost model that actually applies to it.
Lambda Invocation Patterns That Waste Money
Over-Provisioned Memory
Lambda’s pricing is a function of memory allocated multiplied by execution duration — and memory allocation also determines proportional CPU allocation, meaning a function over-provisioned on memory “to be safe” pays for both the unused memory and, often, faster execution than the workload requires but at a higher per-millisecond rate.
# Check actual memory utilization from CloudWatch Logs —
# Lambda reports this automatically in the REPORT line
# "Max Memory Used: 128 MB" against an allocated 1024 MB
# is a clear over-provisioning signal
# AWS Lambda Power Tuning (open-source tool) automates finding
# the cost-optimal memory setting by running the function at
# several memory levels and measuring actual cost per invocation
# rather than guessingA function provisioned at 1024 MB “for headroom” that consistently uses 120 MB is paying roughly 8x more per invocation than a correctly-sized 128–256 MB allocation would cost, often without any corresponding speed benefit since the function was never memory-bound to begin with.
Chained Invocations vs Step Functions
A common anti-pattern in Lambda-based ETL: one function invoking another via a direct SDK call, holding its own billed execution time open while it waits for the downstream function’s response — effectively paying for two functions’ compute time serially, for work that a Step Functions state machine would orchestrate without the calling function needing to stay billed and idle during the wait.
# WRONG — the calling function pays for idle wait time
# while the invoked function runs
import boto3
lambda_client = boto3.client("lambda")
def handler(event, context):
response = lambda_client.invoke(
FunctionName="downstream-processor",
InvocationType="RequestResponse", # synchronous — blocks and bills
Payload=json.dumps(event)
)
return response
# BETTER — Step Functions orchestrates the sequence;
# no function pays to sit idle waiting on another{
"StartAt": "ProcessBatch",
"States": {
"ProcessBatch": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:process-batch",
"Next": "ValidateOutput"
},
"ValidateOutput": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:validate-output",
"End": true
}
}
}For any ETL pattern with more than one sequential Lambda step, Step Functions is very often both the more cost-correct and the more observable choice — the sequential-invocation-via-SDK pattern is one of the more common silent cost leaks in Lambda-based pipelines specifically because it looks like normal working code, not a misconfiguration.
The Audit Process - Where to Actually Look
1. Pull the AWS Cost Explorer breakdown by service, filtered to
the data platform's account or tag, for the last 90 days.
Identify which 2-3 services are actually driving the total -
don't optimize uniformly across everything.
2. For S3: check the Storage Lens dashboard or a simple
`aws s3api list-objects-v2` age analysis for objects
still in Standard past 30-60 days with no recent access.
3. For Glue: pull DPUSeconds and ExecutionTime for each job's
recent runs. Compare against the job's allocated MaxCapacity —
a large, consistent gap signals over-provisioning.
4. For Athena: check the "Data Scanned" column in query history
for the platform's most frequently-run queries. Cross-reference
against whether the underlying table is partitioned and columnar.
5. For Lambda: pull the REPORT log lines for the platform's
functions and compare Max Memory Used against the configured
memory allocation across a representative sample of invocations.
This audit, run once, is what surfaced every fix in the opening story — none of it required new tooling, only someone actually looking at the specific numbers behind the aggregate bill.
The AWS Cost Optimization Checklist
S3
□ Lifecycle policies exist for raw/rarely-requeried data,
not left indefinitely in Standard
□ Intelligent-Tiering applied to datasets with unpredictable
access patterns
□ Storage class audit run periodically, not just once
Glue
□ DPU allocation is checked against actual utilization,
not left at its original creation-time value indefinitely
□ Job bookmarks are enabled AND transformation_ctx is set
correctly for bookmark tracking to actually function
□ Auto-scaling considered for jobs with variable data volume
Athena
□ Frequently-queried tables are partitioned on the columns
actually used in WHERE clauses
□ Frequently-queried tables are in a columnar format (Parquet/ORC),
not CSV or JSON
□ Data Scanned per query is monitored, not just query latency
Lambda
□ Memory allocation is checked against actual Max Memory Used,
not set once "for headroom" and left unexamined
□ Sequential multi-step Lambda chains use Step Functions
rather than synchronous SDK invocations that bill idle wait time
Final Takeaway
None of the fixes in this audit required new infrastructure, a platform migration, or a rewrite of pipeline logic. They required looking at the specific numbers behind an aggregate bill that had been reviewed, until the CFO’s question, only as a single line that kept climbing.
Cloud cost creep in data platforms is rarely one mistake. It’s a set of reasonable defaults from eight months ago that nobody has gone back to check against the platform’s current, different reality.
📌 Core Principle
The AWS bill is not a mystery. It is a sum of specific decisions, most of them made once and never revisited. Revisit them.
Next in Series
Azure Data Engineering Cost Control
The audit pattern in this post — look at the specific line items, not the aggregate — applies just as directly on Azure, with a different set of specific cost centers.
Next: Databricks cluster cost management, ADF pipeline run optimization, ADLS Gen2 storage cost patterns, and the Synapse serverless vs dedicated pool decision — where Azure’s cost model compounds invisibly in ways that are structurally similar to AWS but specific enough to need their own audit.