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.
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
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:
- Compute: peak QPS ÷ per-instance capacity × headroom → instance count × hourly price × 730 h.
- Database: instance class needed for peak writes and working set; add replicas.
- Storage: total GB × price per GB-month, plus growth.
- Egress: GB served per month × price (and how much a CDN absorbs).
- 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.
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.