Lesson 5 of 10 Data Pipeline Design Patterns

Optimising Pipeline Cost and Performance

This lesson explains the handful of techniques that improve both the cost and the speed of data pipelines, which spend most of their money on data scanned, compute provisioned and data stored.

Learning outcomes

After completing this lesson, you will be able to:

  • Reduce data scanned with columnar formats, compression and partitioning.
  • Pay for less compute with right-sizing and incremental processing.
  • Reduce storage cost with lifecycle rules and compaction.
  • Track spending with tags and Cost Explorer.

Scan less data

Athena and Redshift Spectrum charge by the data scanned, so reading less data makes queries both cheaper and faster. Converting CSV and JSON to Parquet or ORC lets queries read only the columns they need, often scanning 80–90% less. Partitioning by the most common filter, usually date, lets queries skip whole partitions, and partition projection avoids slow partition listing when there are very many.

Compacting many small files into files of about 128 MB to 1 GB reduces the overhead of opening each one and improves parallelism. Compression with Snappy or ZSTD reduces storage and I/O. Materialised views and query result reuse avoid recomputing the same aggregation for each user. The following table summarises the techniques.

TechniqueEffect
Convert CSV and JSON to Parquet or ORCColumnar reads; often 80–90% less data scanned
Partition by the most common filter (usually date)Queries skip whole partitions
Partition projection in AthenaAvoids slow partition listing with many partitions
Compact small files to 128 MB–1 GBFewer requests and better parallelism
Compress with Snappy or ZSTDLess storage and I/O
Materialised views and result reuseAvoid recomputing the same aggregation

The following diagram shows how much data the same Athena query scans after each of several optimisations.

Data scanned by the same query at each step. Gzipped JSON scans the whole table, about 1.2 TB. Partitioning by event_date removes about 99% of it, Parquet then reads only five of 60 columns, and compaction removes per-file overhead, leaving about 2 GB per query.
The intermediate values are approximate.
Match the pairs

Scanning less

Exam skills 1.2.4 · 2.4.5

Match each problem with the technique that reduces data scanned.

Log in to try this activity Interactive activities are free with an account.

Pay for less compute

Compute costs fall when capacity matches the work and nothing is processed twice. In AWS Glue, auto scaling removes idle workers during a run, Flex execution runs non-urgent jobs on spare capacity at a lower price, and job bookmarks ensure each run processes only new data. In Amazon EMR, Spot Instances for task nodes, transient clusters that terminate after their jobs, and EMR Serverless all avoid paying for idle or full-price capacity.

For Amazon Redshift, Redshift Serverless suits intermittent workloads, and provisioned clusters can be paused when idle or resized to fit. For unpredictable traffic, on-demand capacity mode in Kinesis Data Streams and DynamoDB avoids paying for capacity provisioned for peaks. The following table summarises the techniques.

TechniqueApplies to
Glue auto scaling and Flex execution for non-urgent jobsAWS Glue
Spot Instances for task nodes; transient clusters; EMR ServerlessAmazon EMR
Redshift Serverless for intermittent workloads; pause and resize provisioned clustersAmazon Redshift
Job bookmarks to process only new dataAWS Glue
On-demand capacity mode for unpredictable streamsKinesis Data Streams, DynamoDB
Sort into groups

Which saving applies?

Exam skills 1.2.4

Match each compute saving with the service it applies to.

Log in to try this activity Interactive activities are free with an account.

Store less, for less

Storage costs grow steadily in a data lake unless they are managed. S3 lifecycle rules move raw data to S3 Standard-IA or Glacier storage classes once it has been processed, because it is read rarely afterwards. For data whose access pattern is unknown or changes, S3 Intelligent-Tiering moves objects between tiers automatically based on actual access, without retrieval fees.

Table formats and streams accumulate hidden storage too. Iceberg snapshot expiry and orphan file removal stop old table versions from accumulating indefinitely, and Kinesis retention should be set to the replay window the pipeline actually needs and no longer, because extended retention is charged.

Track and control spending

Optimisation needs visibility of where the money goes. AWS Cost Explorer shows spending over time by service, account and cost allocation tag, so tagging every pipeline resource with its project and environment reveals which pipeline, job or team drives cost; it also forecasts spending and recommends Savings Plans. AWS Budgets alerts by email or SNS when actual or forecast spending passes a threshold, for example a monthly budget for the analytics account, and budget actions can apply a restrictive policy automatically. Athena workgroup data limits add a per-query or per-workgroup control. The following table summarises the tools.

ToolUse for
AWS Cost ExplorerAnalysing and forecasting spend by service, account or tag
AWS BudgetsAlerts and actions when actual or forecast spend passes a threshold
Cost allocation tagsAttributing cost to pipelines, teams and environments
Athena workgroup data limitsStopping or alerting on queries that scan too much data
Match the pairs

Cost tools

Exam skills 1.2.4

Match each need with the cost tool that meets it.

Log in to try this activity Interactive activities are free with an account.
Worked example

Cutting an Athena bill

A team's Athena bill is $6,000 a month. Queries filter on event_date and read five of 60 columns from gzipped JSON stored as thousands of 1 MB files.

-- Before: every query scans the whole table (~1.2 TB)
SELECT user_id, COUNT(*) FROM events_json WHERE event_date = '2026-10-08' GROUP BY user_id;

-- After: Parquet, partitioned by event_date, files compacted to ~256 MB
SELECT user_id, COUNT(*) FROM events WHERE event_date = '2026-10-08' GROUP BY user_id;
-- Scans one partition, five columns: ~2 GB

Partitioning removes about 99% of the data by date, Parquet removes most of the remaining columns, and compaction removes per-file overhead. The bill falls to well under $100 a month and queries run in seconds instead of minutes.

Check yourself

Which features make a pipeline process only data that changed?

Show answer

Glue job bookmarks for files, and change data capture for databases.

Exam Tips

Remember for the exam

  • Parquet + partitioning + compaction is the standard answer to slow or expensive queries.
  • Spot task nodes, Glue Flex and Redshift Serverless reduce compute cost.
  • Job bookmarks and CDC process only what changed.
  • Lifecycle rules and Iceberg snapshot expiry control storage cost.
  • Alert when pipeline spending is forecast to exceed a threshold: AWS Budgets; analyse spend by tag: Cost Explorer.