Worked Example: 10x Cost Cut

Concepts covered: Pipeline Monitoring

analytics.sessions_enriched builds user sessions from raw click events. At $40,000 a month it tops the cost rollup, and its spend grew 40% in 6 months while the team grew 10%. The owner team runs a cost pass in 3 stages: read lineage, pull the levers in order, and verify each change against the observability pillars before the next.

ComponentHow it runsMonthly cost
TransformFull rebuild of 36 months, hourly: 720 runs at $40$28,800
Consumer queriesSix readers query a 140-column unpartitioned table$7,200
StorageRaw events for 36 months plus 30 kept copies of the output$2,800
Dev and CIFull-volume clones rebuilt nightly$1,200
Total$40,000

Stage 1: read lineage before changing anything

ReaderReadsNeeds data byQueries in 90 days, excluding auto-refresh
Exec revenue dashboardDaily06:00 UTC2,100
Marketing attribution jobDaily06:00 UTC90
ML feature jobDaily05:00 UTC90
Ops live dashboardHourlyToday, within 1 hour8,400
Legacy funnel dashboardEvery 15 minutesNo SLA0
Retention test dashboardEvery 15 minutesNo SLA0

Of the 6 readers, 2 dashboards refresh every 15 minutes and have had no human queries in 90 days, and 3 readers look once a day. Only the ops dashboard needs data within the hour, and only for today. An hourly rebuild of 36 months exists to serve 1 reader's need for 1 day of data.

Stage 2: pull the levers in order

LeverChangeMonthly total after
Stop doing itRetire the 2 unread dashboards, saving $4,800 in queries; delete the 30 output copies, saving $1,200, since snapshots already keep 7 days$34,000
Run less oftenFull build moves to daily at 04:00 UTC; a small hourly job writes only today's partition, at $1.50 a run$7,480
Recompute lessThe daily build rewrites the last 3 days, the late-data window, instead of 36 months: $40 a run becomes $12$6,640
Scan lessOutput partitioned by event date; builds and readers select 22 of 140 columns; dev and CI use a 1% key sample$4,020
Pay less per unitCluster shrinks from 32 to 8 nodes; runs take longer but cost $8 daily and $0.75 hourly$3,780

Run less often removed $26,520, the largest share, because no reader needed what hourly full rebuilds produced. Scan less shrank each daily run from $12 to $10 and each hourly run from $1.50 to $1.00, halved the readers' query bill to $1,200, and cut dev and CI to $200. Storage settled at $1,600 because raw events stay for 36 months under the retention policy. Pay less per unit came last because it tunes a job every earlier lever had already shrunk.

Another team copies this pass for a pipeline whose only reader is a fraud model that scores each payment within 2 minutes of the event. Which lever is ruled out by the reader's needs before any cost data is pulled?

After the pass: raw click events feed an hourly job that overwrites today's partition and a daily build that rewrites the last 3 days. Both publish through pillar checks into the partitioned table the 4 remaining readers query.
  • raw_click_events (bronze, event lake, 36 months)
  • hourly_today_job (transform, orchestrator); freshness: 1 hour; parallelism: 8 nodes; retries: 3; idempotency: overwrite today's partition
  • daily_window_build (transform, orchestrator); freshness: 04:30 UTC; parallelism: 8 nodes; retries: 3; backfill: rewrite last 3 days; idempotency: partition overwrite
  • pillar_checks (quality gate, freshness, volume, schema, distribution); on error: block publish; alerting: page owner team
  • sessions_enriched (gold, partitioned by event_date)
  • exec_revenue_dashboard (consumer, dashboard)
  • attribution_job (consumer, batch job)
  • ml_feature_job (consumer, batch job)
  • ops_live_dashboard (consumer, dashboard)
  • raw_click_events -> hourly_today_job
  • raw_click_events -> daily_window_build
  • hourly_today_job -> pillar_checks
  • daily_window_build -> pillar_checks
  • pillar_checks -> sessions_enriched
  • sessions_enriched -> exec_revenue_dashboard
  • sessions_enriched -> attribution_job
  • sessions_enriched -> ml_feature_job
  • sessions_enriched -> ops_live_dashboard
  • Raw: raw_click_events
  • Build: hourly_today_job, daily_window_build
  • Gate: pillar_checks
  • Serving: sessions_enriched
  • Readers: exec_revenue_dashboard, attribution_job, ml_feature_job, ops_live_dashboard

Stage 3: verify with the 5 pillars

Each lever shipped as a shadow build first: the new logic wrote analytics.sessions_enriched_v2 for 7 days beside the old table, and readers switched only after the comparison passed. A cost cut that changes the numbers is a data incident with a smaller bill.

PillarWhat was checkedPass condition
FreshnessDaily build finish time; lag of today's partitionDaily done by 04:30 UTC; today under 1 hour behind
VolumeSessions per event date, old versus v2Exact match for days older than 3 days
SchemaNames and types of the 22 columns readers selectNo change
DistributionMedian session length, null rate of `user_id`, sessions by countryWithin 1% of the old table each day
LineageQuery log on retired tables; reader job statusZero reads of retired tables, zero reader failures
WITH before_cut AS (
  SELECT
    event_date,
    count(*) AS sessions
  FROM analytics.sessions_enriched
  WHERE event_date >= DATE '2026-10-01'
  GROUP BY
    event_date
),
after_cut AS (
  SELECT
    event_date,
    count(*) AS sessions
  FROM analytics.sessions_enriched_v2
  WHERE event_date >= DATE '2026-10-01'
  GROUP BY
    event_date
)
SELECT
  coalesce(b.event_date, a.event_date) AS event_date,
  b.sessions AS old_sessions,
  a.sessions AS v2_sessions
FROM before_cut AS b
FULL OUTER JOIN after_cut AS a
  ON b.event_date = a.event_date
WHERE b.sessions IS DISTINCT FROM a.sessions
ORDER BY
  event_date

On the last shadow day the query returned 2 rows, the 2 most recent days. That is expected: the old table rebuilt every hour and had already absorbed late events that v2 picks up at its next 04:00 run. A mismatch on any day older than 3 days would mean events arriving outside the late-data window, and the switch would have waited until the window was widened and the run cost recalculated.

The rollup shows sessions_enriched at $9,300 a month, 6 weeks after the switch. It ran 1,440 times last month, and each kind of run costs what it did after the pass. What happened, and where does it surface 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.