Cost Engineering

Cost Engineering

Cost is a design constraint, not a monthly report. The ten drivers that actually move an infrastructure bill, why the ones nobody predicts are always the ones that move bytes rather than store or compute on them, and how to make spend a signal an engineer reads.

▶ Run the lab

The question this answers

Infrastructure question

What does this architecture cost to run, and which line item is the one nobody predicted?

Application requirement

The platform has to serve its users within a budget the business agreed before the architecture existed. Design decisions made in a review — a second region, a NAT per zone, debug-level logging, a cache in front of a cheap query — each commit money for as long as the system runs, and the engineers making them usually cannot see the number they are committing.

What it provides

A model of which components drive spend and in what shape, so an architecture decision can be argued with its cost attached rather than discovered at the end of the quarter.

Application RequirementInfrastructure RequirementComputeNetworkStorageIdentityDeploymentScalingReliabilityObservabilitySecurityCostTrade-offs

Ten drivers, and the three that surprise people

Infrastructure bills are made of a small number of meters. Learning the *shape* of each one — does it charge for existing, for use, or for spikes — is more durable than learning any price, because prices change every year and shapes do not. The panel below is the full driver list with relative weights for a mid-sized web platform. Treat the weights as a teaching illustration, never as a forecast for your system: an image-heavy media product and a batch analytics pipeline have completely different profiles.

Three items are marked as surprises, and they earn it. Data transfer surprises because moving bytes frequently costs more than storing them, and because nothing about the architecture diagram suggests that the arrow between two boxes has a meter on it — see Egress: Moving Data Costs Money, Not Just Storing It. NAT and load balancer charges surprise because they are infrastructure plumbing that nobody thinks of as a product; a per-zone NAT with a per-gigabyte processing charge quietly taxes every image pull and every log shipment. Observability surprises because it scales with traffic *and* with verbosity, so a debug flag left on in production can move it more than a traffic doubling would.

Idle capacity is on the list deliberately, and it is the largest single item in most real bills. Provisioned-but-unused compute is paid for at the same rate as compute doing work. That does not make it waste — some of it is the reliability budget that keeps a traffic spike from becoming an outage — but it does make it the first place to look, and Idle Capacity: Headroom or Waste? is where the headroom-versus-waste distinction gets made properly.

ILLUSTRATIVE driver weights for a mid-sized web platform. Relative bars, never currency, and never a forecast for your system.ILLUSTRATIVE
Compute fixed
driven by instance-hours × size, or vCPU-seconds for usage-shaped platforms · Usually the largest line, and the one most affected by right-sizing and by scale-in that never happens.
Idle capacity · surprisefixed
driven by provisioned minus used, billed identically to used · Not automatically waste — some of it is failover and burst headroom. See Idle Capacity: Headroom or Waste?.
Managed database fixed
driven by instance size × hours, plus storage, plus IOPS or provisioned throughput · Read replicas and multi-zone standbys multiply this line before they touch anything else.
Storage usage
driven by GB stored × month, plus per-request charges on object stores · Cheap per GB and growing monotonically; the fix is lifecycle policy, not a bigger discount. See Storage Lifecycle: Hot, Warm, Archive, Delete.
Data transfer out · surpriseusage
driven by GB leaving the provider network, plus cross-region and cross-zone GB · Moving data often costs more than keeping it. Cross-zone chatter between microservices is the version nobody sees.
NAT and load balancers · surprisefixed
driven by device-hours × zones, plus GB processed · Plumbing with a per-gigabyte meter. Zone redundancy multiplies the hourly part — a real cost of doing reliability properly.
Observability · surprisespiky
driven by log GB ingested, metric series retained, traces sampled · Scales with traffic and with verbosity, and peaks during incidents. See Infrastructure Logs.
Cross-region replication usage
driven by GB replicated × frequency, plus duplicate standby capacity · The honest price of multi-region, and the reason Multi-Region Deployment is a requirement rather than a default.
AI inference / accelerators spiky
driven by GPU-hours, or tokens processed for hosted model APIs · GPU-hours bill whether or not the accelerator is busy, which makes utilization the whole game. See GPU and Accelerator Infrastructure.
Support, licences and commitments fixed
driven by plan tier, per-node licences, reserved capacity purchased · Commitments trade flexibility for a lower rate and are a bet on your own capacity forecast.

Bars are relative weights, not currency. Real rates depend on provider, region, commitment and volume.

Every architecture decision has a meter attached

The practical technique is to make the cost visible at the moment the decision is made, in the review, next to the availability and latency arguments. Not a price — you cannot know the price, and the guide is explicit that no figure here is a fact — but the *driver* and the *shape*. "We are adding a NAT per zone" becomes "we are adding three fixed hourly charges plus a per-gigabyte meter on all outbound traffic, in exchange for egress surviving a zone failure". That is a sentence a team can actually weigh.

The matrix maps common decisions to what they turn on. The pattern that emerges is worth naming: decisions that add *redundancy* multiply fixed costs, decisions that add *hops* add usage-shaped costs, and decisions that add *observability* add spiky costs that peak when you are already having a bad day. A design that adds all three at once — multi-region, service mesh, full-fidelity tracing — has tripled its cost surface before it serves a single extra user.

The second thing to establish is who sees the number. Cost data that only reaches finance produces a quarterly conversation about discounts. Cost data that reaches the engineers who created the line item produces architecture changes, which is where the real savings are. That requires attribution, which requires tagging, which is Cost per Service and the Attribution Problem.

DecisionMeter it turns onShapeThe honest counterweight
Add a second availability zoneDuplicate compute, a second NAT, cross-zone transferFixed + usageThis is what surviving a zone failure costs — see Multi-Zone Deployment
Add a second regionDuplicate everything, plus continuous replication trafficFixed + usageOften 1.8–2.2× the single-region bill for a requirement few products actually have
Split a monolith into servicesCross-zone traffic between services, more load balancers, more log streamsUsageNetwork chatter that used to be a function call now has a meter on it
Add a managed cacheNode-hours, always onFixedWorth it if it removes database load; pure cost if the query was already cheap
Turn on debug logging in productionLog ingestion, immediately, at multiplesSpikyThe single fastest way to move an observability bill
Serve media from the origin instead of a CDNInternet egress at origin rates, on every requestUsageA CDN usually costs less per GB than the origin egress it replaces — see CDN as Infrastructure
Autoscale on a slow signalOvershoot: instances that scaled out and lingeredSpikyA scale-in cooldown that is too conservative is a permanent cost
Keep every backup foreverStorage growing monotonically plus retrieval when testedFixedRetention is a recovery decision with a bill — see Backup Strategy
Run your own database instead of managedInstance-hours and engineer-hoursFixedThe instance is cheaper and the on-call is not — see Managed vs Self-Hosted
Common architecture decisions and the meters they switch on

The cost view over a topology

The same overlay habit that produces the Security View produces a Cost View, and it is read the same way: take the topology you already have and annotate what each node and each edge meters. The edges matter as much as the nodes here, which is the part that catches people — a diagram where two boxes talk to each other across zones is a diagram with a meter on the arrow.

The topology below flags four things on an unremarkable design. A NAT per zone that all image pulls traverse. Cross-zone traffic between the API tier and the database standby. A log pipeline shipping to an external vendor, billed twice. And a development environment identical in size to production, running twenty-four hours a day to serve a team that works eight. None of these are architectural mistakes; all of them are decisions that were made without their cost attached.

That last one deserves emphasis because it is the easiest large saving in most organizations and it requires no architectural change at all. Non-production environments that run continuously to serve people who work business hours are paying roughly three times what they need to. Scheduled shutdown is unglamorous, low-risk and frequently worth more than a quarter of right-sizing work.

An ordinary design with the Cost View applied. Four flags, none of them architectural mistakes.ILLUSTRATIVE
Region
Zone A
API tier (zone A)private
NAT (zone A)public
Primary database (zone A)private
Zone B
API tier (zone B)private
NAT (zone B)public
Standby (zone B)private
Load balancerpublic— Hourly charge plus per-GB processed.
Dev environment (production-sized, 24/7)private
External logging vendorpublic
Load balancerAPI tier (zone A)· GB processed
Load balancerAPI tier (zone B)· GB processed + cross-zone
API tier (zone A)NAT (zone A)· per-GB processed
API tier (zone B)Primary database (zone A)· cross-zone transfer, per GB
Primary database (zone A)Standby (zone B)· continuous replication, per GB
API tier (zone A)External logging vendor· internet egress + vendor ingestioncrosses boundary

Key points

  • Learn the shape of each meter — fixed, usage or spiky — not the price. Shapes survive the annual pricing change; prices do not.
  • The line items that surprise teams are the ones that move bytes: data transfer, NAT processing, log ingestion.
  • Idle capacity is usually the single largest item, and part of it is deliberately purchased reliability rather than waste.
  • Attach the driver and the shape to every architecture decision in the review, where it can still change the design.
  • Redundancy multiplies fixed costs, extra hops add usage costs, and observability adds spiky costs that peak during incidents.
  • Cost data that only reaches finance produces discount negotiations; cost data that reaches engineers produces architecture changes.

The loop, answered

Every field is required, which is why no lesson here can recommend something without saying what it costs and what simpler thing to consider first.

How it works
  • Every provider resource is attached to one or more meters: time-based (per hour of existence), volume-based (per GB stored, transferred or ingested), or operation-based (per request or per invocation).
  • Usage is aggregated per account or project, per region, per service and per tag, then rated against a price book that varies by region, tier and commitment.
  • Commitments and reservations apply a lower rate in exchange for a promise of minimum usage over one to three years.
  • Cost and usage data is published as a detailed dataset, typically a day or more behind, which is why anomaly alerting is a separate mechanism from the bill.
  • Attribution to a team or service is only possible where tags were applied at resource creation — untagged shared resources have to be allocated by an agreed rule instead.
What you still own
  • Set a budget with alerts at a rate threshold, not only at a monthly total, so a step change is caught on day two rather than after invoicing.
  • Review the top five line items monthly and ask what changed. It is a thirty-minute meeting that regularly finds more than a week of optimization work.
  • Tag at creation time and enforce it in the IaC module, because retroactive tagging never completes.
  • Schedule non-production environments off outside working hours before doing any clever optimization.
  • Revisit commitments as the architecture changes — a three-year reservation on an instance family you migrated away from is a pure loss.
  • Give every recurring cost an owner. Unowned line items grow indefinitely.
How it fails
  • A silent step change: something scaled out, or a log level changed, and the new baseline is only visible on the invoice weeks later.
  • Optimization theatre: weeks spent shaving 5% off compute while data transfer and idle capacity, together larger, go untouched.
  • Cost-driven decisions that damage reliability — removing the standby, cutting headroom to zero, deleting backups — which is Idle Capacity: Headroom or Waste? read badly.
  • Untagged shared resources that nobody claims, so the largest costs are the least attributable.
  • Commitment lock-in: reserved capacity that no longer matches the architecture, paid for regardless.
  • A runaway loop — retry storms, recursive function invocations, a misconfigured crawler — that bills in hours what was budgeted for a month.
How it scales
  • Compute cost tracks traffic if scaling works and tracks provisioned capacity if it does not, which is why scale-in matters as much as scale-out.
  • Data-transfer cost grows super-linearly when a system is decomposed, because internal calls that were free become metered network hops.
  • Storage grows monotonically and never scales down by itself; only a lifecycle policy makes it decrease.
  • Observability cost grows with traffic multiplied by verbosity multiplied by cardinality, and cardinality is the term with no natural ceiling.
  • The dimension that runs out first is usually organizational: past a few teams, nobody can attribute spend without tagging discipline that was not there from the start.
Security
  • Cost anomalies are a security signal. Cryptomining on compromised compute, data exfiltration through egress, and a leaked key being used at scale all show up as unexplained spend before they show up anywhere else.
  • Billing data reveals architecture — service names, regions, resource counts. Treat access to it as production information.
  • Budget alerts that halt or throttle spend can become an availability risk; decide deliberately whether a budget stop is allowed to take production down.
  • Cost pressure is a common driver of insecure shortcuts: skipping a private endpoint, disabling audit logging, reducing environment separation. Name the security cost when it happens.
Cost shape
  • Three shapes: fixed (billed for existing), usage (billed for volume), spiky (billed for bursts you did not plan).
  • The dominant items in most bills are compute, idle capacity, managed databases and data transfer — in that rough order and with wide variance by workload.
  • The items that surprise are transfer, NAT processing and observability, all of which are invisible on an architecture diagram.
  • Every figure in this module is illustrative. Actual rates depend on provider, region, tier, commitment and negotiated agreement.
What to watch
  • Daily spend rate by tag, which surfaces a step change in a day instead of a month.
  • Cost per unit of business value — per thousand requests, per active tenant — which is the only metric that distinguishes growth from waste.
  • Anomaly detection on the top line items, tuned to rate of change rather than absolute value.
  • Percentage of spend that is attributable, tracked as a health metric of the tagging discipline itself.
  • The signal that lies: total monthly spend. It rises with growth and hides a doubling of cost per request underneath an increase everyone expected.
Simpler alternatives
  • For a small system, one budget alert and a monthly look at the top five line items covers nearly all the value. A cost-management platform is not the starting point.
  • A simpler architecture is the strongest cost control available: fewer components, fewer hops, fewer meters. Most cost work is undoing complexity that was never justified.
  • Provider-native cost tooling before third-party platforms, which are themselves priced as a percentage of the spend they analyse.
  • If the bill is small relative to engineering salaries, the correct decision is usually to stop optimizing and ship features — an honest answer that cost tooling vendors rarely give.
What adopting this costs
  • Making cost visible buys better architecture decisions; it costs tagging discipline, review time and the risk of optimizing the wrong thing enthusiastically.
  • Commitments cut the rate and remove flexibility precisely when a re-architecture would otherwise be attractive.
  • Cutting idle capacity saves money and consumes the buffer that absorbs traffic spikes and failover. That trade must be made deliberately.
  • Cost attribution needs tagging discipline that slows resource creation slightly and pays back only when there are enough teams to argue about the bill.

Where the bill actually comes from

Where the bill actually comes from
Toggle the architecture and watch the shape of the spend, not a price. Fixed weight is committed the moment you provision; usage weight only moves when the workload does.
right-sized to
Headroom is capacity you deliberately keep empty to absorb a spike, a deploy and a failed peer — it is the reliability budget. Waste is capacity nobody chose and nobody watches. The bill cannot tell them apart; only the sizing decision can.
managed database — reserved fixed
observability pipeline — usage · surpriseusage
application instances — reserved fixed
NAT gateway — usage · surpriseusage
object storage — usage usage
managed database — usage usage
NAT gateway — reserved · surprisefixed
load balancer — reserved fixed
load balancer — usage usage
application instances — usage usage
observability pipeline — reserved · surprisefixed
the reserved compute envelope, split honestly
35% used
25% headroom
40% waste
total weight
39
fixed / usage
46% / 54%
paid for and idle
7.2 of 18
zone × region factor
fixed weight is committed at provision time; usage weight follows the workload.
idle = 100% − 35% used  →  headroom 25% (chosen) + waste 40% (not chosen)
40% of the reserved envelope is neither used nor deliberately reserved. Fixed-shape lines (46% of the weight here) pay that in full every hour regardless of traffic — an idle instance, an idle managed database and an idle load balancer all bill exactly like busy ones. The fix is a smaller envelope or autoscaling, not a discount.
COST-VARIESILLUSTRATIVErelative weights only — real ratios depend on provider, region, commitment and volume

What people believe, and what is true

Claim

Cloud is cheaper than owning servers.

Reality

It converts capital expenditure into operating expenditure and buys elasticity. For a steady, predictable, high-utilization workload, owned hardware is frequently cheaper — see On-Premises vs Cloud.

Claim

Compute is the bill.

Reality

Compute is usually the largest single item and rarely a majority. Transfer, idle capacity, managed data services and observability together typically exceed it.

Claim

Cost optimization is a finance activity.

Reality

The large savings are architecture changes — remove a hop, add a CDN, fix the scale-in policy, delete an environment. Finance can negotiate a rate; only engineers can remove a meter.

Claim

We will optimize once it becomes a problem.

Reality

By then the architecture has been built around the expensive shape, and changing it costs a migration. Cost is cheapest to influence in the design review.

Apply it