Cost of revenue and cloud margins: the engineer's lever on profit
What goes into cost of revenue for SaaS and AI products, why gross margin drives valuation, and how engineering, FinOps and pricing decisions move it, with worked examples.
Key takeaways
- Cost of revenue is the cost of serving paying customers. It's the line engineering influences most directly.
- Gross margin decides how much of each euro funds R&D, sales and profit, and investors value revenue by it.
- Measure cost per unit (per customer, per request, per GB) so cost scales visibly with value.
- AI inference is a variable cost per request. Price and design AI features so margin survives heavy users.
- Agree classification rules with finance and tag resources so costs land in the right place automatically.
Of all the lines in a software company's income statement, cost of revenue is the one engineering influences most directly. Architecture choices, infrastructure contracts, the AI models you call and how well production runs all show up there, and through it in gross margin, one of the numbers investors care about most.
This guide explains what belongs in cost of revenue, why gross margin matters so much, and the practical levers engineering leaders have. It continues with Northwind Cloud from finance fundamentals.
#What goes into cost of revenue
Cost of revenue, also called COGS or cost of sales, is the cost of delivering the service to customers who already pay. For a software company it typically includes:
- Production hosting: cloud compute, storage, databases and bandwidth for customer-facing systems
- Third-party services built into the product: payments, email and SMS delivery, maps, AI model APIs
- Customer support, and often part of customer success
- People who deliver onboarding and professional services
- Production operations, such as on-call and site reliability work (company policies vary)
- Amortization of capitalized software in some companies, though many put it in R&D or a separate D&A line
Usually not in cost of revenue: development and staging environments, engineers building new features (R&D), sales and marketing tools, and internal IT.
Note Classification policies differ between companies, and they matter: moving a cost from R&D into cost of revenue lowers gross margin without changing profit. Agree the rules with finance, write them down, and tag cloud resources so costs land in the right bucket automatically.
#Northwind's cost of revenue
Northwind's cost of revenue last year was €2.4 million, in EUR thousands:
| Subscriptions | Onboarding services | Total | |
|---|---|---|---|
| Revenue | 9 200 | 800 | 10 000 |
| Hosting | 1 100 | 1 100 | |
| Customer support | 400 | 400 | |
| Payment fees and third-party APIs | 300 | 300 | |
| Onboarding team | 600 | 600 | |
| Cost of revenue | 1 800 | 600 | 2 400 |
| Gross profit | 7 400 | 200 | 7 600 |
| Gross margin | 80% | 25% | 76% |
Splitting it this way shows two businesses with very different economics. The subscription earns 80%, a healthy SaaS margin. Onboarding earns 25%, which is fine for services but means every euro of services revenue dilutes the company's margin. If services grew faster than subscriptions, overall gross margin would fall even though nothing got worse.
#Why gross margin matters
Gross margin = (revenue − cost of revenue) ÷ revenue
Gross margin is the share of each euro that's available to fund R&D, sales and marketing, G&A and, eventually, profit. Three reasons it gets so much attention:
- It caps profitability. A company with a 60% gross margin can never have an operating margin above 60%, and in practice far below.
- It drives valuation. Investors pay more for revenue that converts to gross profit. A software company at 80% margin and one at 60% can be valued very differently on the same revenue.
- It's hard to fix later. Architecture decisions made early, such as single-tenant deployments, expensive data stores or a dependency on a costly API, are expensive to undo.
Rough reference points: mature SaaS 75–85%; infrastructure-heavy or support-heavy SaaS 60–75%; products built on paid AI inference often 50–65%, improving as model costs fall.
#Unit costs: the language that connects engineering and finance
Total cloud spend is hard to judge. Is €1.1 million a year a lot? It depends on what it buys. Unit costs make cost comparable to value:
- Northwind's hosting is about €2 750 per customer per year (1 100 ÷ 400 customers), or about 12% of subscription revenue.
- Other useful units: cost per active user, per 1 000 API requests, per GB stored, per transaction, per AI request.
Track unit costs over time and by customer tier. Total cloud spend should rise as the business grows; unit costs should be flat or falling. If cost per customer rises with no new features to show for it, something is wrong: a new inefficient service, an unused environment, a missing lifecycle policy.
Unit costs also show which customers and features are profitable. A small number of very heavy customers on flat pricing can cost more to serve than they pay. That's a pricing conversation, and you can only have it with data.
#Engineering levers on margin
| Lever | Typical impact |
|---|---|
| Right-size and autoscale compute | 10–30% of compute cost |
| Commitments (savings plans, reserved capacity) for steady load | 20–50% discount on that load |
| Storage lifecycle policies (hot → cold → delete) | Large for data-heavy products |
| Efficient queries, indexes and caching | Smaller databases, fewer replicas |
| Multi-tenant architecture | Much lower cost per customer |
| Turning off idle environments | Often a quick 5–10% of non-production spend |
| Reducing data transfer between regions and clouds | Significant for chatty architectures |
| Automating support work and improving self-service | Slower growth in support headcount |
Commitments deserve care. A three-year commitment can cut costs sharply, but it's a fixed cost that doesn't shrink if usage does, and it may need board approval as a significant contract. Finance will want to know about it, and it belongs in the cash forecast.
#FinOps in practice
FinOps is the practice of making cloud spending a shared responsibility of engineering, finance and product. A practical version:
- Tag everything by environment, team, product area and customer tier, and enforce tagging in infrastructure code.
- Allocate costs to cost of revenue or R&D using the agreed rules, so finance doesn't have to guess at month end.
- Show unit costs on team dashboards, next to latency and error rates.
- Review monthly. A short review of the biggest movements catches most problems early.
- Make cost a non-functional requirement in design reviews, alongside security and reliability.
- Forecast with finance. Expected growth, planned launches and commitments should feed the budget, not surprise it.
#AI features change the math
Traditional SaaS has high fixed costs and low marginal costs: one more customer barely changes the cloud bill. AI features reverse that. Every request to a model costs money, so cost rises directly with usage.
Suppose Northwind adds an AI assistant to every plan at no extra charge. Its average customer has 40 users, each making about 300 requests a month, at about €0.004 per request:
40 users × 300 requests × €0.004 = €48 per customer per month, or €576 a year
Across 400 customers that's about €230 000 a year, all of it in cost of revenue. Gross margin falls from 76% to about 73.7% with no new revenue. And averages hide the problem: a power user making 3 000 requests a month costs €12 a month on their own. If the feature were priced at €5 per user, those users would lose money on every month of use.
Ways to keep AI features profitable:
- Estimate cost per user per month at realistic and heavy usage before launch, not just the average.
- Route by difficulty: use smaller, cheaper models where quality allows and send only hard cases to large ones.
- Cache and trim: reuse results for repeated questions, and limit the context sent with each request.
- Batch work that doesn't need an instant answer, which is often much cheaper.
- Price for usage: credits, tiers or fair-use limits, so heavy users pay for what they use.
- Monitor per feature and per customer, so you see margin erosion as it happens.
Warning A popular AI feature on a flat-price plan can quietly turn your best customers into your least profitable ones.
#Gross margin and the rest of the P&L
Gross margin doesn't stand alone. A team that moves support work into product improvements may lower cost of revenue while raising R&D. A cheaper hosting architecture that needs more engineers to run may save less than it seems. Look at the total cost of a decision, and agree with finance where each part lands.
#Common mistakes
- Treating cloud cost as an IT overhead rather than a cost of each sale.
- Mixing production and non-production costs, which hides real unit economics.
- Optimizing total spend instead of unit cost. Growth should raise the bill; efficiency should lower the unit.
- Signing large commitments without finance, or without a usage forecast.
- Launching AI features without a cost model for heavy users.
- Reclassifying costs between R&D and cost of revenue to flatter gross margin.
#Questions to ask
- What's our gross margin, split by subscription and services, and how has it trended?
- What's in cost of revenue, and what's the classification policy for engineering and operations?
- What's our cost per customer, and which customers or features cost most to serve?
- What share of cloud spend is tagged and allocated automatically?
- What commitments have we made to cloud providers, and how much headroom do we have?
- What does each AI feature cost per user at heavy usage, and how is it priced?
Next in the series: budgeting and headcount planning, where these costs meet the annual plan.
General information, not financial, tax or legal advice. Tax rates and thresholds are for 2026; check them with your tax agency or adviser.
Keep reading
How to price a software product: value metrics, tiers, discounts, annual vs monthly billing, price increases and usage-based pricing, and how each choice moves revenue, margin, retention and cash.
Read a P&L like a CFO: revenue, cost of revenue, gross margin, operating expenses, EBITDA, D&A, EBIT, interest, tax and net income, with a worked SaaS example and a calculator.
Why a signed deal isn't revenue: bookings vs billings vs revenue, deferred revenue, RPO, and the five-step model of IFRS 15 and ASC 606 in plain language, with a worked SaaS contract.