System design concepts · Running It for Real

Cost Engineering and Capacity Planning for System Design

A design that works but costs more than the business earns is a design that fails slowly. Senior engineers treat money as a first-class requirement, right next to latency and availability.

What you'll be able to explain
  • Find where the money goes in a typical cloud architecture
  • Estimate the monthly cost of a design from your capacity numbers
  • Plan capacity with headroom, peaks and failover in mind
  • Apply the highest-leverage cost optimisations, and know the traps
  • Talk about cost trade-offs convincingly in an interview

Why cost belongs in design

Cost used to be "someone else's problem" when hardware was bought once a year. In the cloud, every architectural decision is a line on a monthly bill: a chatty microservice boundary becomes a cross-AZ data transfer charge; a forgotten debug log becomes a terabyte of log ingestion; an always-on GPU becomes a car payment.

Interviewers increasingly ask, "roughly what would this cost?" or "how would you make this cheaper?" You don't need exact prices. You need to know which components dominate and which levers move them.

Analogy

Running a system is like running a household. Rent (always-on servers) is predictable and big. Electricity (compute that scales with use) moves with your habits. Then there are sneaky subscriptions you forgot about (idle resources, old snapshots, log retention). Saving money mostly means cutting the sneaky stuff and right-sizing the rent, not turning off the lights while you're reading.

Where the money goes

Compute (VMs, containers, functions)~35–45%Databases (managed, incl. replicas)~20–30%Storage + backups~5–15%Data transfer (egress, cross-AZ)~5–15% (often a surprise)Observability (logs, metrics, traces)~5–15%Everything elsequeues, DNS, support…
A typical web product's cloud bill by category (illustrative; your mix will differ).

Cost drivers to know

Component Mainly priced by Classic surprise
Compute vCPU-hours and memory-hours Over-provisioned instances idling at 8% CPU
Managed DB Instance size, replicas, IOPS, storage Provisioned IOPS nobody uses; 3 replicas in dev
Object storage GB-month + requests + retrieval Millions of tiny objects; PUT/GET request charges
Egress GB leaving the cloud or crossing AZs/regions Video served from origin instead of a CDN
CDN GB delivered, requests Usually cheaper than origin egress
Logs GB ingested and retained Debug-level logging in production
Functions Invocations × duration × memory Cheap at low volume, expensive at steady high volume
GPUs GPU-hours Idle inference servers between bursts

Estimating cost from your numbers

Use the capacity estimate you already made (Back-of-the-Envelope Estimation for System Design Interviews) and attach rough unit prices. The method:

  1. Compute: peak QPS ÷ per-instance capacity × headroom → instance count × hourly price × 730 h.
  2. Database: instance class needed for peak writes and working set; add replicas.
  3. Storage: total GB × price per GB-month, plus growth.
  4. Egress: GB served per month × price (and how much a CDN absorbs).
  5. Add 20–30% for observability, backups, environments and "everything else".

Worked example: a photo-sharing MVP

Item Estimate Rough monthly cost
API servers 2,000 peak QPS ÷ 500 per instance × 1.5 headroom = 6 small instances ~$300
Database 1 primary + 1 replica, mid-size ~$700
Cache 2 small Redis nodes ~$150
Object storage 50 TB of photos ~$1,100
CDN egress 300 TB/month, at volume pricing ~$6,000–$9,000
Observability, backups, misc. ~25% ~$2,000
Total ~$10,000–$13,000

The lesson pops out immediately: delivery bandwidth dominates, so the biggest savings come from image compression (WebP/AVIF), right-sized thumbnails, high CDN hit rates and maybe a cheaper CDN contract, not from shaving an API server.

Tip

Always find the dominant cost first. Optimising a 3% line item is a waste of a week. In media products it's bandwidth; in data products it's storage and query scanning; in AI products it's GPU time; in chatty microservices it's often cross-AZ transfer and observability.