
Building Cost-Optimized Data Lakehouse Pipelines on AWS in 2024
The rising costs of cloud data storage and compute have made cost-optimized data lakehouse pipelines essential for enterprises in 2024. As generative AI workloads and analytics volumes surge, engineering teams must balance agility with financial efficiency. In this post, I'll show you how to architect a modern, production-ready AWS lakehouse pipeline that minimizes costs without sacrificing performance or flexibility.
What Is a Lakehouse Pipeline? Real Config Example
A lakehouse pipeline combines the scalability of data lakes (S3, GCS, Azure Data Lake) with the transactional reliability of data warehouses (like Snowflake, Redshift, or BigQuery). The core idea: use open formats (Parquet, Apache Iceberg, Delta Lake) to enable ACID transactions, schema evolution, and time travel on top of cheap object storage.
Here's a real-world Glue job config (AWS Glue 4.0) for ingesting data into an Iceberg-backed lakehouse table on S3:
import sys
from awsglue.context import GlueContext
from awsglue.job import Job
from pyspark.context import SparkContext
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
# Iceberg table location in S3
iceberg_table_path = "s3://my-lakehouse/warehouse/db/events/"
# Read JSON data from S3
input_df = spark.read.json("s3://my-lakehouse/raw/events/2024-06-01/")
# Write as Iceberg table (v1.3.0) with partitioning
input_df.write \
.format("iceberg") \
.option("path", iceberg_table_path) \
.option("write-format", "parquet") \
.option("partitioning", "event_date") \
.mode("append") \
.saveAsTable("db.events")
Key insight: Modern lakehouse pipelines use open table formats like Iceberg with low-cost S3 storage, orchestrated by Glue, to deliver warehouse-like reliability at a fraction of the cost of traditional data warehouses.
Step 1: Choose an Open Table Format (Iceberg vs Delta Lake vs Hudi)
Why Open Table Formats Matter
Open table formats let you run ACID transactions, handle schema evolution, and support time travel directly on data in S3. In 2024, Apache Iceberg (v1.3.0+), Delta Lake (v3.0+), and Apache Hudi (v0.14+) are the three leading options. Iceberg is natively supported by AWS Glue, Athena, EMR, Redshift Spectrum, and even Snowflake. Delta Lake is strong in Databricks and now supported by Athena v3. Hudi excels at incremental upserts and streaming use cases.
How to Configure Iceberg on AWS Glue
In your Glue job, set the table format to Iceberg and configure partitioning for cost-efficient queries:
input_df.write \
.format("iceberg") \
.option("partitioning", "event_date") \
.saveAsTable("db.events")
Key insight: Open table formats future-proof your lakehouse, ensuring compatibility with a broad ecosystem and avoiding cloud vendor lock-in.
Step 2: Optimize Storage and Partitioning for Cost
S3 Storage Classes and Costs
S3 Standard costs $0.023/GB/month, while S3 Intelligent-Tiering can cut storage bills by 20–50% for rarely accessed data. In production, I use Bucket Lifecycle Policies to transition aged partitions to S3 Glacier Instant Retrieval ($0.004/GB/month) after 90 days.
Partitioning Patterns
In my experience, partitioning by event_date (YYYY-MM-DD) or business key (e.g., customer_id) keeps query costs low. But over-partitioning ("small files problem") can slow jobs and balloon AWS Glue costs. I recommend targeting 100–200MB Parquet file sizes. Use Glue's "Optimize Partition" feature or run periodic Spark jobs to compact small files.
Key insight: Align partitioning with common query patterns and automate file compaction to slash both storage and compute costs.
Step 3: Automate Data Pipeline Orchestration
Glue Workflows, Step Functions, or Airflow?
Glue Workflows provide native orchestration, but for complex dependencies or integration with ML, AWS Step Functions or MWAA (Managed Workflows for Apache Airflow) are better. I recommend defining pipelines as code using Airflow DAGs for version control and CI/CD. Example Airflow DAG using the AWS-provided GlueOperator:
from airflow import DAG
from airflow.providers.amazon.aws.operators.glue import GlueJobOperator
from datetime import datetime
default_args = {
'retries': 2,
'retry_delay': timedelta(minutes=5),
}
dag = DAG(
dag_id='lakehouse_etl_v1',
default_args=default_args,
schedule_interval='@daily',
start_date=datetime(2024, 6, 1),
catchup=False,
)
run_glue_job = GlueJobOperator(
task_id='run_ingest',
job_name='iceberg_ingest_job',
script_location='s3://my-lakehouse/scripts/ingest.py',
dag=dag
)
Key insight: Automated orchestration with Airflow or Step Functions ensures reliable, repeatable data pipelines and supports production-level alerting and retries.
Comparing Lakehouse Table Formats and Orchestration Tools
| Feature | Iceberg (v1.3+) | Delta Lake (v3.0+) | Hudi (v0.14+) |
|---|---|---|---|
| AWS Native Support | Glue, Athena, EMR | Athena, EMR, Databricks | EMR, Athena (limited) |
| ACID Transactions | Yes (Full) | Yes (Full) | Yes (Full) |
| Schema Evolution | Yes (Flexible) | Yes (Good) | Yes (Good) |
| Time Travel | Yes | Yes | Yes |
| Incremental Upserts | Medium | Medium | Best |
| Best for | Analytics, AI, BI | Databricks, ML | Streaming, CDC |
Key orchestration trade-offs:
- Glue Workflows: Easiest AWS integration, but limited for cross-service pipelines.
- Step Functions: Great for event-driven, serverless pipelines; integrates with Lambda.
- Airflow (MWAA): Best for complex, multi-system orchestration and CI/CD.
Key insight: Choose your table and orchestration framework based on your primary use case, AWS integration needs, and team skillsets.
Frequently Asked Questions
Q: How do I choose between Iceberg, Delta Lake, and Hudi for my AWS pipeline? A: If you need broad AWS Glue/Athena/Redshift compatibility and strong analytics, use Iceberg. If you're on Databricks, choose Delta Lake. For Change Data Capture (CDC) and streaming upserts, Hudi shines.
Q: What's the most cost-effective way to store cold data in a lakehouse? A: Use S3 Lifecycle Policies to move old partitions to S3 Glacier Instant Retrieval after 90–180 days. This can reduce storage costs by up to 80% for infrequently accessed data, with minimal impact on query latency.
Q: How can I prevent the 'small files problem' in my Iceberg tables? A: Schedule nightly or weekly file compaction jobs (using Glue or Spark on EMR) targeting 100–200MB Parquet files. This improves read efficiency, lowers Athena query costs, and boosts Glue ETL throughput.
Key Takeaways
- Open table formats like Iceberg (v1.3+) enable ACID transactions and schema evolution on S3, unlocking warehouse-like features in your lakehouse.
- Use S3 Intelligent-Tiering and automated lifecycle transitions to cut storage costs by 20–80% for cold data.
- Partition tables by query keys (event_date, customer_id) and routinely compact files to avoid costly small-file overhead.
- Orchestrate pipelines with Airflow (MWAA) or Step Functions for production reliability, CI/CD, and robust error handling.
- Glue 4.0 jobs natively support Iceberg and can run cost-efficient, serverless ETL at scale.
- Monitor your pipeline's S3, Glue, and Athena costs monthly—small architectural tweaks (like partitioning or file size) can yield major savings.


