SD System Design In Depth
0%
lesson system-designrequirementscost

Cost-aware architecture

Module 1.1: Foundations & System Invariants Updated Sep 17, 2026
📄 Cheat Sheet
AWS re:Invent 2023 - Keynote with Dr. Werner Vogels
Amazon Web Services AWS re:Invent 2023 - Keynote with Dr. Werner Vogels Watch on YouTube ↗

The keynote where Werner Vogels introduced "The Frugal Architect": cost as a non-functional requirement, aligning cost with business revenue, and measuring cost per unit of work. The first hour is directly on topic.

0:00 / --:--

Under the Hood: Cloud Economics as a Primary Constraint

In cloud-native distributed systems, architectural decisions map directly to recurring monthly operational expense. An architecture that achieves single-digit millisecond latency by over-provisioning memory clusters or continuously replicating terabytes across availability zones without considering network egress is functionally flawed. Cost-Aware Architecture establishes unit economics (e.g., compute and bandwidth cost per active user or per transaction) as a first-class engineering metric.

Cloud Cost Levers Breakdown

flowchart LR subgraph IngressEgress ["Network Transfer"] E1["Internet Outbound Egress: Expensive ($0.08 - $0.12 / GB)"] E2["Cross-AZ Traffic: Hidden Cost ($0.01 / GB each way)"] E3["Intra-AZ Private IP: Free ($0.00 / GB)"] end subgraph StorageCompute ["Compute & Storage Tiering"] C1["Spot / Preemptible: 60-90% Discount"] C2["Reserved / Savings Plans: 30-50% Discount"] S1["S3 Standard -> Infrequent Access -> Glacier Archival"] end

Production Cost Optimization Mechanics

1. The Cross-Availability-Zone Network Trap

Engineers often assume intra-cloud network traffic is free. Cloud providers charge for cross-AZ data transfer in both directions. If microservice A in AZ-1 calls database replica B in AZ-2 with uncompressed gigabytes of JSON data, the monthly network transfer bill can eclipse compute costs. Mitigate this with AZ-affinity routing, gzip/Zstandard compression, and binary serialization (Protobuf).

2. Multi-Tiered Storage Lifecycle Automation

For many workloads, access frequency drops sharply with age and most reads target recent data (measure your own access pattern, for example with S3 Storage Class Analysis). Retaining multi-year logs, raw user uploads, or audit events in hot object storage (S3 Standard) wastes capital. Automated lifecycle rules transition data from Standard ($0.023/GB/mo) to Infrequent Access ($0.0125/GB/mo) to Glacier Deep Archive ($0.00099/GB/mo) (us-east-1 list prices, which vary by region and change over time). That cuts the per-GB storage price by over 95% for rarely read data, but retrieval fees and minimum storage durations (30 days for Standard-IA, 180 days for Deep Archive) apply.

3. Compute Blending: On-Demand vs. Spot Capacity

Stateless batch processors, asynchronous queue workers, and data analytics pipelines are good candidates for Spot capacity instead of full-price On-Demand instances. Blending an On-Demand baseline (for example around 20%) with Spot capacity for the rest, diversified across instance types behind auto-scaling groups, cuts compute spend while tolerating preemptions; the right split depends on the workload.

Worked example: pricing the shortener's traffic

Use illustrative AWS us-east-1 list prices (they change; always check the current pricing page): internet data transfer out about 0.09 USD per GB for the first 10 TB per month, cross-AZ transfer 0.01 USD per GB in each direction, S3 Standard about 0.023 USD per GB-month, S3 Glacier Deep Archive about 0.00099 USD per GB-month.

  • Redirect responses: 100 million redirects per day with a response of about 500 bytes including headers is about 50 GB per day, roughly 1.5 TB per month, or about 135 USD per month of egress. Small.
  • Click events across zones: if each redirect writes a 300 byte event to a database primary in another availability zone, that is 30 GB per day crossing zones. With replication to a standby in a third zone, the bytes cross twice. At 0.01 USD per GB each way, the cost is a few tens of dollars per month, still small, but it grows linearly with any payload you add.
  • Event history storage: 100 million events per day at 300 bytes is about 30 GB per day, about 11 TB per year. Five years in S3 Standard would be about 55 TB, roughly 1,265 USD per month at the end. Moving events older than 90 days to Deep Archive brings the bulk of it to roughly 55 USD per month, at the cost of retrieval times measured in hours.

The lesson: for this product, storage retention policy dominates, not the request path. For a video or image product, egress would dominate instead, which is why such products use CDNs with negotiated rates.

Cost levers and their trade-offs

LeverTypical savingWhat you give up
Reserved instances or savings plansOften around 30 to 60% versus on-demandOne to three year commitment
Spot or preemptible instancesUp to about 90% versus on-demandInstances can be reclaimed with short notice (2 minutes on AWS)
Storage lifecycle tiersLarge for cold dataRetrieval fees, minimum storage duration, slower access
Zone-affine routingRemoves cross-AZ transferUneven load if one zone is busier; failover must still work
Compression and binary encodingOften several times fewer bytes on the wireCPU time and harder debugging
CDN cachingLower origin egress and computeStaleness and invalidation complexity
Right-sizing and autoscalingRemoves idle capacityLess headroom for sudden spikes

Failure modes

  • Runaway costs from bugs: a retry loop or log flood can multiply the bill overnight; set budgets and billing alerts.
  • Unexpected NAT gateway charges: traffic from private subnets to AWS services through a NAT gateway is charged per GB processed; VPC endpoints avoid much of it.
  • Cheap storage, expensive reads: infrequent-access tiers charge per GB retrieved, so frequently read data can cost more there than in Standard.
Check yourself Question 1 of 3
Poor fit for Spot recall
From: Production Cost Optimization Mechanics

Spot or preemptible capacity can be reclaimed at short notice. Which workload is the poorest fit for it?

Key Takeaways

Cross-Availability-Zone data transfer is a major hidden cloud cost; use AZ-aware routing and payload compression.
Tier storage automatically using lifecycle rules: S3 Standard for hot data, Glacier Deep Archive for compliance logs.
Blend On-Demand baseline compute with Spot/Preemptible instances for fault-tolerant background workloads.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue