Lesson 19 / 30

What Actually Drives the Bill

List the main cloud cost drivers and map each capacity estimate to a billable unit.

By · 15 years in web development

Capacity estimates become line items

A cloud bill is your capacity estimate multiplied by unit rates. The main drivers are: compute (instance-hours or vCPU-hours and memory, or per-invocation and duration for serverless); storage (GB-months, priced differently for block, object and archive tiers, plus per-request charges on object stores); data transfer (especially egress to the internet and sometimes traffic between zones or regions); managed services (databases, queues, caches, search clusters, priced by node size, throughput units or requests); and operational extras such as load balancers, NAT gateways, logs and metrics ingestion, which are easy to forget and can surprise a team. To model cost, take each estimate from earlier sections and attach the billing unit: servers x hours per month, TB stored x GB-month rate, egress GB x transfer rate. The structure matters more than the rates, which change and vary by region.

From capacity to money

A capacity estimate is converted into billing units, multiplied by unit rates, and summed into a monthly cost.

Four connected stages: capacity estimate, billing units, unit rates, monthly cost.
Figure 7.1: capacity estimate -> billing units -> unit rates -> monthly cost

A monthly cost model

All rates below are made-up placeholders for practice; always take real rates from your provider's current pricing page.

HOURS_PER_MONTH = 730
rates = {                      # placeholder rates, USD
    "server_hour": 0.20,
    "storage_gb_month": 0.02,
    "egress_gb": 0.08,
}
usage = {
    "servers": 42,
    "storage_gb": 133_700,
    "egress_gb": 300_000,
}
cost = {
    "compute": usage["servers"] * HOURS_PER_MONTH * rates["server_hour"],
    "storage": usage["storage_gb"] * rates["storage_gb_month"],
    "egress": usage["egress_gb"] * rates["egress_gb"],
}
for item, usd in cost.items():
    print(f"{item:8s} ${usd:>10,.0f}")
print(f"{'total':8s} ${sum(cost.values()):>10,.0f} per month")

Output:

compute  $     6,132
storage  $     2,674
egress   $    24,000
total    $    32,806 per month

Hidden line items

Logs and metrics ingestion, NAT gateway data processing, cross-zone traffic and idle development environments regularly show up as unexpected costs. Ask about them in design reviews.

Quick check: Which item is most often forgotten in a first cost estimate?

  • The number of application servers
  • Logging, monitoring and data-transfer charges between zones or to the internet
  • The size of the primary database
  • Object storage for user uploads
Answer

Logging, monitoring and data-transfer charges between zones or to the internet — Servers and primary storage are obvious. Observability ingestion and network transfer charges are less visible but can be significant.