The previous lesson ended with a warning: in an elastic platform, what grows without warning is the bill. In an on-premises data center, spending is decided once, when the machines are bought, and someone in Finance signs it off. In the cloud it is decided every day by anyone who runs a query, schedules a refresh or leaves an environment switched on. Cost has stopped being a purchasing decision and has become a property of the architecture, just like performance or security, and like them it is designed, measured and monitored.
This lesson explains what the cost of a data platform is made up of, how to estimate it, how to make it visible, which levers reduce it and how limits are placed on it. DataCorp will build its cost model against the cap of €4,000 a month in RQ-12, check what is left of the business case of lesson 01-02 and set its policy in ADR-018.
Why data costs in the cloud are different
| On-premises infrastructure | Pay-as-you-go cloud | |
|---|---|---|
| Nature | Investment (it is bought) | Operating expense (it is rented) |
| When it is decided | Once, before buying | Continuously, with every use |
| Who decides it | Purchasing and management | Every engineer and every analyst |
| Relationship to usage | Fixed: using more does not cost more | Variable: every query is paid for |
| Main risk | Falling short or overbuying | Spending without noticing |
| When it is known | Beforehand | Afterward, on the bill |
Three traits make data spending especially easy to send through the roof:
- There is no friction. Running a query that reads a terabyte takes the same effort as one that reads a megabyte.
- The person who spends does not see the price. The analyst sees the result; the bill reaches another department weeks later.
- Data only grows, and with it the cost of every badly written query.
None of this is an argument against the cloud: paying only for what is used is exactly what makes DataCorp's platform viable. It is an argument for managing it.
Anatomy of the cost and total cost of ownership
| Line item | What is paid for | Usual unit | Behavior |
|---|---|---|---|
| Storage | Data stored, depending on the class | € per GB per month | Predictable; it grows with volume |
| Transformation compute | Running loads and models | By data read or by time | Proportional to what is reprocessed |
| Query compute | Queries from people and dashboards | By data read (€ per TB) or by compute time (€ per hour) | The most variable; it depends on how people query |
| Data egress | Data leaving the cloud or the region | € per GB | Easy to forget (lesson 02-03) |
| Managed services | Orchestrator, messaging, catalog, monitoring | Fee by environment size and hour | Fixed: it is paid even if not used |
| Licenses | BI and other tools | Per user or per plan | Fixed, in steps |
| People | The team that builds and operates | Salaries | The largest item, and the one that shows up least |
The two billing models for query compute behave in opposite ways:
| By data read | By compute time | |
|---|---|---|
| What is paid for | Each query, according to the GB it scans | The hours the engine is switched on |
| Cost when idle | Zero | Zero only if it suspends automatically |
| Suits | Sporadic use and small volume | Intense, continuous use |
| Optimized by | Reading less (pruning, columns, aggregates) | Taking less time and switching off sooner |
| Risk | One enormous query | An engine switched on with no work |
DataCorp chose the first in ADR-017: with 40 users and 2 GB a day, paying for what is read costs a tenth as much.
The total cost of ownership (TCO) adds up everything it costs to have the platform, not just the cloud bill: rollout, operation, licenses, training and people. Comparing on the bill alone leads to wrong decisions; the classic example is deploying an open source tool yourself "because it's free" and spending half of an engineer's working day operating it.
DataCorp's cost model
A cost model is an estimate by line item, with the assumptions in plain sight, that is corrected with the real bills. The rates are illustrative; what matters is the structure. Usage assumptions for the engine (ADR-017), at €5 per terabyte read: the transformations read about 150 GB a day (4.5 TB a month) and the queries from people and dashboards, about 9 TB a month.
RQ12_CAP = 4000.0 # EUR/month (RQ-12)
PRICE_PER_TB = 5.0 # EUR per TB read by the SQL engine (illustrative rate)
LOAD_TB = 4.5 # TB read per month by the transformations (load group)
QUERY_TB = 9.0 # TB read per month by people and dashboards (query group)
def line_items(query_tb):
"""Returns the monthly cost of each line item, in EUR."""
return {
"Object storage": 10.00, # lesson 02-03
"SQL engine, load group": LOAD_TB * PRICE_PER_TB,
"SQL engine, query group": query_tb * PRICE_PER_TB,
"Managed orchestrator": 420.00, # fixed cost: small environment
"Managed messaging (clickstream)": 310.00, # fixed cost
"Ingestion and micro-batch containers": 95.00,
"PostgreSQL read replica": 180.00, # fixed cost (ADR-001)
"BI tool (Metabase)": 400.00, # ADR-013
"Logs, metrics and alerts": 60.00,
"Private network and data egress": 75.00,
"Development environment and CI": 140.00,
"Provider support plan": 100.00,
}
baseline = line_items(QUERY_TB)
total = sum(baseline.values())
print(f"{'Line item':<38}{'EUR/month':>9}{'% total':>9}")
for name, amount in sorted(baseline.items(), key=lambda p: -p[1]): # largest to smallest
print(f"{name:<38}{amount:>9,.2f}{amount / total * 100:>8.1f}%")
print(f"{'TOTAL':<38}{total:>9,.2f}{total / RQ12_CAP * 100:>8.1f}% of the cap")
# Sensitivity analysis: only the usage of the query group changes
refreshes = 60 * 12 * 22 # one refresh per minute, 12 h a day, 22 days
scenarios = {
"Baseline (9 TB)": 9.0,
"Twice the users (18 TB)": 18.0,
"One dashboard on the detail, every minute": 9.0 + refreshes * 30 / 1000, # 30 GB per refresh
}
print()
for name, tb in scenarios.items():
t = sum(line_items(tb).values())
warning = " <-- EXCEEDS THE CAP" if t > RQ12_CAP else ""
print(f"{name:<42}{tb:>7.1f} TB{t:>10,.2f} EUR{warning}")Line item EUR/month % total Managed orchestrator 420.00 22.6% BI tool (Metabase) 400.00 21.5% Managed messaging (clickstream) 310.00 16.7% PostgreSQL read replica 180.00 9.7% Development environment and CI 140.00 7.5% Provider support plan 100.00 5.4% Ingestion and micro-batch containers 95.00 5.1% Private network and data egress 75.00 4.0% Logs, metrics and alerts 60.00 3.2% SQL engine, query group 45.00 2.4% SQL engine, load group 22.50 1.2% Object storage 10.00 0.5% TOTAL 1,857.50 46.4% of the cap Baseline (9 TB) 9.0 TB 1,857.50 EUR Twice the users (18 TB) 18.0 TB 1,902.50 EUR One dashboard on the detail, every minute 484.2 TB 4,233.50 EUR <-- EXCEEDS THE CAP
The line_items function receives the terabytes read by the query group and returns a dictionary with all the line items; that way the same code serves for the baseline case and for the scenarios. How to read the results:
- The platform fits within the budget comfortably: €1,857.50 a month, 46% of the RQ-12 cap. The margin is not a license to spend: it is the reserve for growth and for the unexpected.
- Three quarters are fixed costs. Orchestrator, BI, messaging, replica and support add up to €1,410: they are paid the same with 40 users as with none. In a small platform, the expensive part is not processing data, but keeping the services around it switched on.
- The data itself costs very little. Storing and querying everything adds up to €77.50, 4%. This confirms what lesson 02-03 anticipated: storage is irrelevant.
- The sensitivity is asymmetric. Doubling the users adds €45. By contrast, a single dashboard that queries the clickstream detail (30 GB per refresh) and updates every minute adds €2,376 and breaks the cap all by itself. The smallest line item is the only one that can be multiplied by fifty.
The design consequence is clear: the fixed cost is controlled by choosing which services are contracted (architecture decisions, few and slow), and the variable cost, by placing limits on usage (daily decisions made by many people).
If people are added, the picture changes scale. With a dedication equivalent to 1.5 people (about €82,500 a year, as an assumption), the TCO for the first year is 60,000 + 22,290 + 82,500 = €164,790, and the platform bill accounts for only 13.5%. That is why RQ-13 weighed so heavily in every decision: saving €200 a month with a tool that demands a day of operation a week is a bad deal.
FinOps: principles and cycle
FinOps (from finance and operations) is the practice of managing variable cloud spending collaboratively among engineering, finance and the business. It is not about spending less, but about getting more value out of every euro. Its principles, in summary:
- Shared responsibility: each team is accountable for the cost of what it uses; it is not "Finance's" problem.
- Value-driven decisions: a cost is high or low depending on what it produces.
- Accessible, timely cost data: every day, not on the following month's bill.
- A team or person who coordinates, even if in a small company it is a part-time role.
- Taking advantage of the variable model of the cloud instead of fighting it.
The work is organized in a continuous cycle of three phases:
flowchart LR
A["Inform<br/>see and allocate the spend:<br/>tags, reports, unit cost"] --> B["Optimize<br/>reduce waste:<br/>levers per line item"]
B --> C["Operate<br/>sustain it:<br/>budgets, alerts, monthly review"]
C --> A
The order matters: you cannot optimize what you cannot see. At DataCorp, Íñigo acts as the operational cost owner, Marta is accountable for the budget and the monthly report is presented in the governance committee, where the owners of the domains that generate the spend sit.
Visibility: tagging, allocation and cost per query
Resource tagging
A tag is a key-value pair attached to a cloud resource; the bill can be grouped by tags. DataCorp requires five, already present in the infrastructure as code of lesson 07-01:
| Tag | Values | Question it answers |
|---|---|---|
environment |
dev, pro |
How much does development cost? |
component |
storage, engine, orchestration, ingestion, bi... |
Which piece does the money go to? |
domain |
sales, marketing, operations, support, common |
Who is the money spent for? |
use_case |
UC-01 … UC-06, common |
How much does each use case cost? |
owner |
Person or team | Whom to ask? |
A resource without tags is spend that nobody can explain: CI rejects any infrastructure change that does not include them.
Allocation: showback and chargeback
- Showback: each domain is shown what its usage costs, without being charged for it. It creates awareness with little bureaucracy.
- Chargeback: the cost is charged to each domain's budget. It creates strong incentives, but requires accepted allocation rules and internal accounting.
DataCorp does showback. The common costs (orchestrator, BI, support) are shown separately, without allocating them by debatable criteria. The first report already teaches something: UC-04, the conversion funnel, is the most expensive use case, because the messaging and the clickstream micro-batches exist almost solely for it (about €370 a month), and its priority is medium. That is no reason to eliminate it, but it is a fact its owner should know.
Cost per query and per dashboard
Analytical engines keep a query history. Let's suppose DataCorp exposes it as control.query_log(query_id, user_name, compute_group, origin, start_time, duration_ms, gb_read, sql_text), where origin identifies the dashboard or process that ran the query:
-- The 10 most expensive origins of the last 30 days
SELECT origin,
user_name,
COUNT(*) AS num_queries,
ROUND(SUM(gb_read), 1) AS gb_read,
ROUND(AVG(gb_read), 2) AS gb_per_query,
ROUND(SUM(gb_read) / 1000 * 5.0, 2) AS cost_eur -- 5 EUR per TB
FROM control.query_log
WHERE start_time >= CURRENT_DATE - INTERVAL '30' DAY
AND compute_group = 'query'
GROUP BY origin, user_name
ORDER BY cost_eur DESC
FETCH FIRST 10 ROWS ONLY;- The query groups by origin and user, and converts the GB read into euros using the rate.
gb_per_querydistinguishes two different problems: many cheap queries (a refresh that is too frequent) or a few extremely expensive queries (a filter or an aggregate table is missing).- The 80/20 rule usually holds: a few origins account for almost all the spend. Fixing the top three pays off more than optimizing a hundred.
Optimization levers
| Line item | Lever | How it works |
|---|---|---|
| Storage | Lifecycle and classes | Old data moves to infrequent or archive, or expires (RQ-09) |
| Compression and columnar format | Parquet with zstd takes up an eighth of the space (ADR-004) | |
| Deleting what is not used | Expired snapshots, orphaned files, abandoned tables and copies | |
| Transformation compute | Incremental load | What changed is processed, not the whole history |
| Shortening the reprocessing window | Fewer days reprocessed once updated_at exists |
|
| Query compute | Partition and column pruning | Filtering by date and asking only for the columns needed |
| Aggregate tables | Dashboards read megabytes instead of gigabytes | |
| Result caches | A repeated query is not run again | |
| Limit on data read per query | A runaway query is rejected instead of being paid for | |
| Time-billed services | Shutdown and auto-suspend | Development environments do not work at night |
| Right-sizing | The smallest environment that meets the need | |
| Everything stable | Usage commitments or reservations | A discount in exchange for committing to a consumption level for one or three years |
Two precautions. Usage commitments only pay off on stable, known consumption: committing in the first month is betting blind, and DataCorp will wait until it has six months of bills. And every optimization has its own cost, the time of the person doing it: spending a week to shave €20 a month off the load group is a mistake when the orchestrator costs twenty times more.
Budgets, alerts and quotas
Three mechanisms, from least to most restrictive:
- A budget is a figure for the expected spend over a period and a scope. It does not prevent spending.
- An alert warns when the actual spend, or the spend forecast for the end of the month, crosses a percentage of the budget.
- A quota or limit prevents the spend: it rejects the query or stops the resource.
A generic example of a declarative definition (each provider has its own syntax):
# infrastructure/budgets.yaml (illustrative syntax)
budgets:
- name: data-platform
period: monthly
amount_eur: 2400 # model (1,857.50) + 30% margin
filter:
tags: { owner: data-team }
alerts:
- threshold_pct: 50 # informational: normal halfway through the month
based_on: actual_spend
notify: ["channel:#data-alerts"]
- threshold_pct: 80
based_on: actual_spend
notify: ["channel:#data-alerts", "marta", "inigo"]
- threshold_pct: 100
based_on: actual_spend
notify: ["marta", "inigo", "sergio"]
- threshold_pct: 100 # warns BEFORE it happens
based_on: forecast_spend
notify: ["marta", "inigo"]
- name: query-engine
period: monthly
amount_eur: 150
filter:
tags: { component: query-engine }
alerts:
- { threshold_pct: 80, based_on: actual_spend, notify: ["inigo"] }
quotas:
- compute_group: query
max_gb_per_query: 20 # the 30 GB refresh in the example would be rejected
- compute_group: load
max_gb_per_query: 200- The 50% alert is only worrying if it fires on the 8th; the one on the forecast spend is the most useful, because it extrapolates the current pace and warns while there is still time to correct it.
- The small budget for the query group watches exactly the line item that the sensitivity analysis flagged as dangerous.
- The quota of 20 GB per query would have prevented the third scenario of the model: the query would have failed with a clear message, forcing the use of the aggregate table.
Cost anti-patterns
| Anti-pattern | Why it costs money | Remedy |
|---|---|---|
SELECT * on columnar tables |
It reads every column when two were needed | Ask for specific columns; per-query limit |
| Queries without a partition filter | They scan the whole history | Require the date filter on large tables |
| Dashboards that refresh every minute data that changes once a day | Thousands of identical queries | Refresh equal to the load frequency; cache |
| Dashboards on the detail | They aggregate millions of rows on every visit | Aggregate tables (ADR-014) |
| Development environments left on | The night and the weekend are paid for | Scheduled shutdown; reduced data |
| Duplicate copies "just in case" | Storage, confusion and privacy risk | A single copy; Iceberg time travel |
| Reprocessing the whole history every night | A cost that grows over time | Incremental |
| Logs with indefinite retention | They grow without anyone reading them | Retention of 30 to 90 days |
| Resources with no tags and no owner | Nobody switches them off | Mandatory tags in CI |
| Downloading data out of the cloud | Data egress | Analyze inside; export only results |
Unit economics and business case
Unit economics expresses the cost per unit of business. A bill that goes up 30% is bad news if orders have not changed, and good news if they have doubled; the unit cost tells the two apart.
| Indicator | Calculation | Value |
|---|---|---|
| Cost per order | €1,857.50 / 45,000 orders a month | €0.041 |
| Cost per active user | €1,857.50 / 40 users | €46.44 a month |
| Cost over net sales | €1,857.50 / €2,828,429.75 (October 2026) | 0.066% |
Four cents per order, with an average order value of €66.12. These indicators are tracked every month: if the cost per order rises steadily, the platform is becoming less efficient.
That leaves the question Sergio will ask: is the payback foreseen in the business case being met? Lesson 01-02 calculated 9.7 months with a cost of €48,000 a year. The model estimates €22,290, less than half: with the same formula, 60,000 / (122,160 − 22,290) × 12 = 7.2 months. But that calculation assumed, without saying so, that all the savings started on day one. The roadmap says otherwise: the savings arrive when the phase that produces them is closed.
INVESTMENT = 60000.0
MONTHLY_COST = 1857.50
# Monthly savings unlocked when each phase closes (annual figures from lesson 01-02)
PHASE_1_SAVINGS = (44160 + 18000 + 15000) / 12 # reconciliation, outages and tools
PHASE_3_SAVINGS = 45000 / 12 # stockouts (UC-03)
balance, month = -INVESTMENT, 0
while balance < 0: # until the investment is recovered
month += 1
savings = 0.0
if month > 3: savings += PHASE_1_SAVINGS # from April 2027
if month > 9: savings += PHASE_3_SAVINGS # from October 2027
balance += savings - MONTHLY_COST
if month in (3, 9, 12) or balance >= 0:
print(f"Month {month:>2}: cumulative balance {balance:>10,.0f} EUR")Month 3: cumulative balance -65,572 EUR Month 9: cumulative balance -38,138 EUR Month 12: cumulative balance -13,170 EUR Month 14: cumulative balance 3,475 EUR
The loop moves forward month by month: it subtracts the cost of the platform and adds only the savings of the phases already delivered. During the first quarter the balance gets worse, because money is being paid without any savings yet. The investment is recovered in month 14 (February 2028), not in 9.7. The project is still profitable, but the honest answer is: the cost target is met with plenty of margin and the payback period is not, because the value arrives in phases. And this calculation still assumes that every saving materializes at 100%; we will check it against reality in the next lesson.
ADR-018: cost policy
ADR-018: Data platform cost policy Status: accepted Date: 2027-02-01 CONTEXT RQ-12 limits the cost to 4,000 EUR/month. The model estimates 1,857.50 EUR/month, of which 76% are fixed costs. The engine bills by data read (ADR-017): the line item is small (67.50 EUR), but a single badly designed query can multiply it and exceed the cap. DECISION 1. Operating budget: 2,400 EUR/month. Exceeding it requires Sergio's approval; 4,000 EUR/month is the absolute cap (RQ-12). 2. Alerts at 50, 80 and 100% of the actual spend and at 100% of the forecast. Specific budget of 150 EUR/month for the query group. 3. Mandatory tags on every resource: environment, component, domain, use_case and owner. CI rejects untagged resources. 4. Limits on data read per query: 20 GB in the query group and 200 GB in the load group. 5. The official dashboards query aggregate tables or fact tables with a partition filter, and do not refresh more often than the data is loaded. 6. The development environment uses reduced data and is switched off outside business hours for everything that bills by time. 7. Monthly review (first Monday): spend per line item and per domain, ten most expensive query origins, unused resources and cost per order. It is presented in the governance committee (showback). 8. Operational owner: Íñigo. Accountable: Marta. ALTERNATIVES CONSIDERED A. No policy, reviewing the bill. Rejected: it is detected late. B. Chargeback to the domains. Rejected: disproportionate bureaucracy for 40 users. C. Usage commitments from the start. Deferred until six months of real consumption are available. REVIEW CONDITIONS - Spend above the operating budget for two months in a row. - Engine cost above 400 EUR/month (ADR-017). - Sustained rise in the cost per order. CONSEQUENCES Positive: visible, bounded spend; the worst case is no longer possible. Negative: some legitimate exploratory queries will be rejected and will have to be handled case by case; one hour of review a month.
Common Mistakes and Tips
- Looking at the bill once the month is over. By then the money has been spent. Use alerts on the forecast spend.
- Optimizing what is cheap. Weeks fine-tuning storage (0.5%) while nobody questions the fixed services. Start with the largest line item.
- Taking it for granted that serverless means cheap. It means proportional to usage, for better and for worse.
- Not setting limits "so as not to bother anyone". A query rejected with a clear message is less of a bother than a budget cut.
- Cutting without looking at the value. Switching off the most expensive use case may eliminate the most profitable one. Compare cost with benefit.
- Forgetting about people. The service that saves operating time is usually the cheap one, even if its bill is higher.
- Tip: include cost in the definition of "done": every new model or dashboard states how much data it reads and how often.
Exercises
Exercise 1: The price of a query
The cleansed table of clickstream events takes up 7.5 GB per month of data and has 8 columns of similar size. The engine charges €5 per TB read. Calculate the cost of: (A) a SELECT * over the 13 months retained, with no filter; (B) a query that asks for 2 columns and filters one month. Then calculate the monthly cost of each one if a dashboard runs it 200 times a day for 22 days. What would happen under the policy of ADR-018?
Exercise 2: Switching off the development environment
Of the €140 a month for the development environment, €100 corresponds to services that bill by time and today run all 720 hours of the month. If they are switched off outside business hours (12 hours, 22 days), how much is saved? What is the model's new total?
Exercise 3: Spotting anti-patterns
Read the situation and point out four anti-patterns, with their remedies: "To prepare the Christmas campaign, Dani creates a dashboard that queries the clickstream events directly with SELECT * and sets it to refresh every 2 minutes. Since it is slow, he asks Íñigo for a full copy of the table 'for himself', which is left in a new bucket, without tags. In January nobody remembers what it was for."
Solutions
Exercise 1
- (A) 13 × 7.5 = 97.5 GB = 0.0975 TB → €0.49 per query.
- (B) 7.5 × 2/8 = 1.875 GB → €0.0094 per query, 52 times less (13 times because of the partition and 4 because of the columns).
- In a dashboard (4,400 runs a month): A, 0.4875 × 4,400 = €2,145; B, €41.25.
- Under ADR-018, A is rejected (97.5 GB exceeds the 20 GB limit). B runs, but it breaches point 5: an official dashboard should read
consumption.daily_funnel, which takes up megabytes. Key point: the same data can cost €2,145 or a few cents depending on how the question is asked.
Exercise 2
Hours switched on: 12 × 22 = 264 out of 720, or 36.7%. Cost of the time-billed part: 100 × 264 / 720 = €36.67; savings, €63.33 a month (€760 a year). New total: 1,857.50 − 63.33 = €1,794.17. It is a modest saving obtained with a single scheduling rule and without harming anyone: the kind of optimization worth doing first.
Exercise 3
- Dashboard on the detail with
SELECT *: use the aggregate table and specific columns. - Refresh every 2 minutes of data that is loaded every 15: match the refresh to the load and enable the cache.
- Duplicate copy: a view or an aggregate table; in addition, the copy contains customer identifiers outside the usual access control.
- Resource with no tags and no owner, created by hand: every resource is created through infrastructure as code, with its tags; the monthly review looks for unused resources.
A fifth could be added: nobody asked about the cost before building.
Conclusion
The cost of a data platform in the cloud is variable, it is decided by many people and it is known late, so it must be treated as one more requirement of the architecture. It is made up of storage, transformation and query compute, egress, managed services, licenses and people; the last of these dominate the total cost of ownership. FinOps proposes managing it in a continuous cycle: informing with tags, allocation and unit cost; optimizing with the levers suited to each line item, starting with the largest, and operating with budgets, alerts and quotas.
DataCorp now knows that its platform will cost about €1,857.50 a month, less than half the RQ-12 cap; that three quarters are fixed costs and that the risk lies in the smallest line item, that of the queries; that each order costs it four cents of platform, and that the investment will be recovered around month 14, not in the 9.7 foreseen, because the savings arrive in phases. ADR-018 turns this into policy. With it, eighteen decisions and a plan for putting them into practice are complete. Before closing the module it is worth pausing to look at the whole: which practices have sustained the entire design, which mistakes we have avoided and what DataCorp will have learned when the plan meets reality. That is the subject of the next lesson: best practices and lessons learned.
