Cost: compute, storage and network
Savings Plans and Spot, S3 storage classes and lifecycle rules worked through for the primer’s 36 TB, NAT gateways versus gateway endpoints, and queues.
What you will learn
- Treat cost as a design constraint, and price the primer's design with AWS list prices.
- Choose between On-Demand, Savings Plans and Spot for each workload.
- Cut storage and network bills with lifecycle rules and gateway endpoints.
Cost is part of the design
Cost runs through the primer's AWS exercise. Moving to managed services "could also increase" costs, "but should be weighed with the costs of managing similar systems on your own". Vertical scaling "can get very expensive". The reason given for autoscaling is to cut the cost of servers idle outside business hours.
Prices below are AWS list prices for US East (N. Virginia), taken from AWS's price list in November 2026. They differ by Region and change over time, so check the pricing pages before relying on them.
Paying for compute
| Model | Commitment | AWS's stated saving vs On-Demand | Fits |
|---|---|---|---|
| On-Demand | None | none | Unpredictable or short-lived load |
| Compute Savings Plans | USD per hour for 1 or 3 years | up to 66% | Steady baseline, any instance family or Region, also Fargate and Lambda |
| EC2 Instance Savings Plans | USD per hour for 1 or 3 years, one instance family in one Region | up to 72% | Steady baseline on a fixed family |
| Spot Instances | None, but AWS can reclaim them | up to 90% | Fault-tolerant work, such as the primer's queue workers |
How a Savings Plan bills. You commit to an amount per hour. Each hour, usage is charged at the plan's lower rate until the commitment is used up, and the rest at On-Demand rates. An hour's commitment "cannot be carried over". If the fleet follows the working day, commit to the overnight level and the commitment is always used. Commit to the daytime peak and you pay at night for capacity you do not run. Whether a commitment above the trough pays off depends on the discount; the visual finds the cheapest level.
Spot interruptions. EC2 gives "a warning that is issued two minutes before" it stops or terminates a Spot Instance. A worker that pulls jobs from SQS can stop taking new jobs when warned. Any job it does not finish becomes visible again when its visibility timeout (default 30 s) expires, and another worker can take it.
Storage classes and lifecycle rules
The primer's data grows by 1 TB a month: 36 TB after three years. Kept in S3 Standard, the bill grows every month. A lifecycle rule moves objects to cheaper classes as they age:
| Class | USD per GB-month | Minimum storage duration | Access |
|---|---|---|---|
| S3 Standard (first 50 TB) | 0.023 | none | Milliseconds |
| S3 Standard-IA | 0.0125 | 30 days | Milliseconds; 0.01 USD per GB retrieved |
| S3 Glacier Instant Retrieval | 0.004 | 90 days | Milliseconds; 0.03 USD per GB retrieved |
All three store data in at least three Availability Zones. S3 Standard is designed for 99.999999999% durability.
Worked example. Take 1,000 GB a month for 36 months, with nothing deleted. With no rule:
With "Standard-IA after 30 days, Glacier Instant Retrieval after 90 days", the newest month stays in Standard, the next two months are in Standard-IA, and 33 months are in Glacier Instant Retrieval:
Caveats:
- Transitions are charged per object, and reads from the cheaper classes carry retrieval fees. Data that is read often can cost more there.
- By default, S3 does not transition objects smaller than 128 KB, because the per-object transition charge can exceed the saving.
- The primer's 1 KB writes live in MySQL, not S3. These classes suit its media, uploads, logs and backups.
NAT gateways and gateway endpoints
Instances in a private subnet reach the internet through a NAT gateway. A NAT gateway is charged per hour and per GB it processes; AWS's US East (Ohio) example uses 0.045 USD for each. Traffic from those instances to S3 would otherwise go through the NAT gateway too.
A gateway VPC endpoint for S3 (or DynamoDB) routes that traffic privately inside AWS instead. AWS says: "There are no data processing or hourly charges for using Gateway Type VPC endpoints." At the Ohio rate, 10,000 GB a month of S3 traffic through a NAT gateway costs 450 USD in processing charges, before the hourly charge. Through a gateway endpoint it costs nothing.
Doing less work synchronously
The primer's last step moves work that does not need to happen in real time onto queues and workers. That lowers latency for users, and it lowers cost: workers can scale with the queue, or run on Spot or Lambda.
Two cost levers
S3 storage classes for data that ages, and a Savings Plans commitment for a fleet that follows the working day.
S3 lifecycle
Stored: 1,000 GB Standard, 2,000 GB Standard-IA, 33,000 GB Glacier Instant Retrieval. Monthly storage bill: 180 USD, against 828 USD with no rule.
US East list prices per GB-month: 0.023, 0.0125 and 0.004 USD. Not included: request, transition and retrieval charges; by default S3 does not transition objects under 128 KB.
Savings Plans commitment
Compared with on-demand for the whole day, this saves 15%. Commitment spent on capacity you did not run, over the day: 0.0 (in units of one instance-hour at the On-Demand price). At this discount the cheapest commitment covers about 12 instances.
Key takeaways
- Managed services can cost more, but weigh that against running the same systems yourself; prices vary by Region and change, so check them.
- A Savings Plan bills usage at a lower rate up to an hourly commitment; Spot is cheapest but gives two minutes' warning, which suits queue workers.
- Lifecycle rules moving 36 TB from S3 Standard to Standard-IA and then Glacier Instant Retrieval cut the example's bill from 828 to 180 USD a month, before transition and retrieval fees, which are added on top.
- A gateway endpoint for S3 removes NAT gateway charges on that traffic, and queued work can run on cheaper capacity.
Sources
- System Design Primer: Scaling on AWS, Users+ (cost of managed services)
- Savings Plans User Guide: Savings Plans types and how they apply
- Amazon EC2: Spot Instance interruption notices
- Amazon S3: Transitioning objects using S3 Lifecycle
- Amazon S3 pricing
- Amazon VPC pricing (NAT gateway, gateway endpoints)
- Amazon SQS: Visibility timeout
Adapted from The System Design Primer by Donne Martin, licensed under CC BY 4.0. Changes were made.