Cost Optimization as Ongoing Work

Concepts covered: Pipeline Monitoring

A pipeline's cost moves every month without anyone deciding to move it. Source tables grow, a new dashboard queries the output every 15 minutes, a backfill leaves a full copy behind, and a cluster sized for last year's peak keeps running at that size. A one-time cleanup removes this month's waste and leaves those forces in place, so cost work has to recur on a schedule.

The line spend should stay under

Spend and headcount both grow, and the number worth watching is their ratio. Track spend per data engineer every month. If the team grows 20% and spend grows 20%, each engineer's pipelines cost what they did a year ago. If spend grows 60% over the same year, new work is paying for old waste, and the gap compounds.

MetricLast OctoberThis OctoberGrowth
Data engineers404820%
Monthly data spend$100,000$160,00060%
Spend per engineer$2,500$3,33333%

Last October the team had 40 engineers and spent $100,000 a month on data. This October it has 50 engineers. What is the highest monthly spend that stays at or under the headcount-growth trend?

The 5 levers and their order

A pipeline's monthly bill is runs per month, times data processed per run, times the price of processing each unit of data, plus any work nobody reads. Each lever shrinks 1 of those terms.

LeverTerm it shrinksTypical moveWhat can break
Stop doing itThe whole termRetire tables and refreshes with no reads in 90 daysA hidden reader that lineage missed
Run less oftenRuns per monthHourly to daily where every reader looks dailyA reader with a real freshness SLA
Recompute lessData per runFull rebuild to incremental with a late-data windowLate rows outside the window
Scan lessData per runPartition filters, fewer columns, sampled dev dataA query that loses its partition filter
Pay less per unitPrice per unitRight-sized clusters, cheaper compute for retryable batchSlower runs that miss an SLA

The order matters because the first levers remove work and the last one discounts whatever work remains. Stop doing it removes a whole term and needs nothing but lineage and query logs. Pay less per unit goes last: right-size a cluster before converting its job to incremental and you've sized it for a job about to shrink, so you size it twice.

The monthly cost rhythm

One cycle, 4 weeks

SELECT
  pipeline,
  owner_team,
  sum(if(cost_month = DATE '2026-10-01', cost_usd, 0)) AS oct_cost,
  sum(if(cost_month = DATE '2026-09-01', cost_usd, 0)) AS sep_cost,
  sum(if(cost_month = DATE '2026-10-01', cost_usd, -cost_usd)) AS growth_usd
FROM ops.pipeline_cost_monthly
WHERE cost_month IN (DATE '2026-09-01', DATE '2026-10-01')
GROUP BY
  pipeline,
  owner_team
ORDER BY
  growth_usd DESC
LIMIT 10

Ranking by growth_usd puts a pipeline that jumped from $500 to $9,000 above a steady $20,000 one. The growth list catches new waste while its author still remembers why it exists. The dollar list catches the old giants nobody has questioned in a year, and a saving from last cycle that has crept back shows up in both.

A pipeline costs $18,000 a month. It rebuilds 4 years of order history every hour on a 32-node cluster. Its 3 consumers each read once a day, and 1 has had no queries in 120 days. Which change comes first?

About this lesson

This section is part of the Pipeline Operations: Advanced lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.