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.
| Metric | Last October | This October | Growth |
|---|---|---|---|
| Data engineers | 40 | 48 | 20% |
| Monthly data spend | $100,000 | $160,000 | 60% |
| Spend per engineer | $2,500 | $3,333 | 33% |
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?
- Spend of $140,000, keeping spend growth below 50%
- Spend of $130,000, keeping spend per engineer nearly flat
- Spend of $150,000, funding each of 50 engineers at $3,000
- Spend of $125,000, holding spend per engineer at $2,500
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.
| Lever | Term it shrinks | Typical move | What can break |
|---|---|---|---|
| Stop doing it | The whole term | Retire tables and refreshes with no reads in 90 days | A hidden reader that lineage missed |
| Run less often | Runs per month | Hourly to daily where every reader looks daily | A reader with a real freshness SLA |
| Recompute less | Data per run | Full rebuild to incremental with a late-data window | Late rows outside the window |
| Scan less | Data per run | Partition filters, fewer columns, sampled dev data | A query that loses its partition filter |
| Pay less per unit | Price per unit | Right-sized clusters, cheaper compute for retryable batch | Slower 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
- Week 1: Rank: Pull spend by pipeline tag. List the top 10 by dollars and the top 10 by month-over-month growth.
- Week 2: Assign: Each listed pipeline's owner team names 1 lever and an expected saving, or records why the spend is worth it.
- Week 3: Ship: Make 1 change at a time, so a number that regresses has 1 cause to look at.
- Week 4: Verify: Compare cost per run with the baseline, confirm last cycle's savings still hold, and plot spend per engineer.
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 10Ranking 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?
- Shrink the cluster to 8 nodes, since most of the bill is compute time.
- Retire the unread consumer, then move the build from hourly to daily.
- Convert the build to incremental and keep the hourly schedule as it is.
- Add partition filters to the 3 consumers' queries before touching the build.
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.