Cost-aware design: storage tiers, data transfer, serverless
Cut cost in a design by changing storage tiers, transfer paths or compute model.
By Invicly Tech, , in AWS Solutions Architect – Associate. About 11 minutes to read.
In short
The cheapest architecture often comes from design choices, not discounts. Move cold data to cheaper storage tiers, keep traffic inside an AZ or behind CloudFront, and use serverless or managed services where usage is low or spiky. The exam rewards the option that meets requirements at the lowest cost.
Explained simply
Discounts make each unit cheaper, but design decides how many units you buy. A smart architecture can cost half as much as a careless one doing the same job. The three big levers are where data is stored, how data moves, and what kind of compute runs your code.
Storage is cheap to start but adds up forever. Data that nobody reads should move to cheaper tiers or be deleted. Old snapshots, old log groups and old object versions are classic silent costs that grow every month without anyone noticing.
Data transfer is the cost people forget. Data coming into AWS from the internet is free, but data going out costs money per GB, and so does traffic between Availability Zones, between Regions, and through a NAT gateway. Where you place things and which path traffic takes can change the bill a lot.
Compute is cheapest when it matches the load. A server that runs all month for a few hundred requests a day wastes money; serverless charges only per request. A busy, steady service can be cheaper on right-sized instances. The best answer depends on the shape of your traffic.
Press Play on a diagram to walk through it one step at a time.
- Storage
- Lifecycle to IA and Glacier
- Intelligent-Tiering
- gp3 instead of gp2
- Delete old snapshots
- Data transfer
- CloudFront for egress
- Gateway endpoints, not NAT
- Same-AZ traffic
- Compress payloads
- Compute
- Lambda for spiky loads
- Fargate for small services
- Graviton instances
- Stop idle dev resources
- 1Before
Private subnet to NAT gateway to S3
- 2Measure
NatGateway-Bytes in Cost Explorer
- 3Add gateway endpoint
Route table entry for S3, free
- 4Same AZ for heavy flows
Avoid cross-AZ hops where possible
- 5After
No NAT processing fee for S3 traffic
In depth
Data transfer: the price map
Inbound traffic from the internet is free. Outbound to the internet is charged per GB, with the first 100 GB each month free across services. Traffic between AZs in one Region costs about 0.01 dollars per GB in each direction, so a chatty service talking across AZs pays twice. Traffic between Regions is charged per GB, while traffic inside one AZ over private IPs is free.
NAT gateways charge per hour and per GB processed (0.045 dollars per GB in us-east-1), on top of normal transfer. Gateway endpoints for S3 and DynamoDB are free and remove that NAT charge for those services. Interface endpoints have a much smaller per-GB fee plus an hourly fee. Data from AWS origins such as S3 or an ALB to CloudFront is free, and CloudFront's own internet rates are usually lower than serving directly. Since 2024, every public IPv4 address also costs 0.005 dollars per hour.
- Free
- Inbound from the internet
- Same AZ over private IP
- S3 or DynamoDB via gateway endpoint
- AWS origin to CloudFront
- Small per-GB charge
- Between AZs, each direction
- Interface endpoints
- Larger per-GB charge
- Out to the internet after 100 GB
- Between Regions
- NAT gateway processing
Storage: tier it, size it, expire it
For S3, use lifecycle rules for data with a known age pattern and Intelligent-Tiering when the pattern is unknown, but remember the minimum storage durations and the 128 KB minimum billable size in IA classes. Expire noncurrent versions and abort incomplete multipart uploads, which otherwise stay billed and invisible in normal listings.
For EBS, gp3 costs about 20 percent less per GB than gp2 and gives a 3,000 IOPS baseline at any size, so migrating is usually a free win. Find volumes in the available state (attached to nothing) and old snapshots; EBS Snapshots Archive is much cheaper for snapshots you must keep for months, with a 90-day minimum. For EFS, lifecycle management moves cold files to Infrequent Access or Archive. Set retention on CloudWatch log groups, which never expire by default.
- S3 lifecycle or Intelligent-Tiering by access pattern
- Expire old versions; abort incomplete multipart uploads
- gp2 to gp3: about 20 percent cheaper per GB
- Delete unattached volumes; archive long-kept snapshots
- Set CloudWatch Logs retention
Serverless or servers: doing the math
Lambda charges per request (0.20 dollars per million) and per GB-second of run time (about 0.0000167 dollars on x86 in us-east-1; Arm is about 20 percent cheaper). A function with 512 MB that runs 200 ms uses 0.1 GB-seconds per call. At 3 million calls a month that is 300,000 GB-seconds, about 5 dollars, plus 0.60 dollars for requests, less than a small server that runs all month.
The picture flips under steady heavy load. At hundreds of requests per second all day, the same work costs more on Lambda than on a few right-sized instances or Fargate tasks with a Savings Plan. Remember the hidden costs on both sides: API Gateway per request (HTTP APIs cost much less than REST APIs), and for servers the load balancer, idle capacity and the people who patch them. Questions that say least operational overhead usually favour serverless or managed services.
- Zero cost when idle
- Pay per request and GB-second
- Best for low or spiky traffic
- Gets expensive under constant high load
- Pay per vCPU and GB per second
- No servers to patch
- Good for steady containers
- Fargate Spot for interruptible tasks
- Lowest unit cost at steady high load
- Savings Plans and Spot apply
- You manage OS and scaling
- Idle capacity is wasted money
Small design habits that add up
Turn off what nobody uses. Development environments that run only during working hours (about 50 of 168 hours a week) can save around 70 percent with a schedule, for example with EventBridge Scheduler or the Instance Scheduler solution. Graviton instances typically give better price-performance than comparable x86 types for code that runs on Arm.
Cache to avoid repeated work: CloudFront in front of S3 and APIs cuts both origin load and transfer cost, and ElastiCache or DAX can let you run a smaller database. Compress and batch data before sending it. Keep chatty services in the same AZ where availability allows, but never remove Multi-AZ from a system that must be highly available just to save the inter-AZ charge; the exam punishes options that break a stated requirement to save money.
Learn it in 3 short steps
About 40m each. Track them with a timer in your plan.
- 1Tier storage to cheaper classes~40m
- 2Reduce data transfer costs~40m
- 3Swap servers for serverless where it fits~40m
Key points
- Inbound data transfer is free; outbound to the internet and cross-AZ traffic cost money.
- CloudFront egress is usually cheaper than serving directly from EC2 or S3.
- Serverless costs nothing when idle, so it wins for low or bursty traffic.
- Replace NAT traffic to S3 and DynamoDB with free gateway endpoints.
Key terms
Tap a card to flip it. 0/4 known
Examples
Removing a NAT gateway bill
Private instances download 10 TB a month from S3 through a NAT gateway. At 0.045 dollars per GB processed, that is about 10,240 GB x 0.045 = 461 dollars a month just in NAT processing. Step 1: create an S3 gateway endpoint and attach it to the private route tables. Step 2: traffic to S3 in the same Region now follows the endpoint route, with no NAT fee and no endpoint fee. Step 3: confirm in Cost Explorer that NatGateway-Bytes dropped. Optionally restrict the bucket to that endpoint with aws:SourceVpce.
aws ec2 create-vpc-endpoint --vpc-id vpc-0abc1234 \
--vpc-endpoint-type Gateway \
--service-name com.amazonaws.us-east-1.s3 \
--route-table-ids rtb-0priv1a rtb-0priv1bA low-traffic API: server or serverless?
An internal API gets about 300,000 requests a month, each running 100 ms with 256 MB. Step 1: Lambda compute is 300,000 x 0.1 s x 0.25 GB = 7,500 GB-seconds, about 0.13 dollars, plus about 0.06 dollars for requests. Step 2: an API Gateway HTTP API adds about 0.30 dollars at 1 dollar per million requests. Step 3: compare with even the smallest always-on instance plus a load balancer, which costs tens of dollars a month before patching time. Serverless wins clearly here; revisit the decision if traffic grows to constant high load.
requests = 300_000
gb_seconds = requests * 0.1 * 0.25 # duration (s) x memory (GB)
lambda_compute = gb_seconds * 0.0000166667 # x86, us-east-1
lambda_requests = requests / 1e6 * 0.20
http_api = requests / 1e6 * 1.00
print(round(lambda_compute + lambda_requests + http_api, 2)) # about 0.49 dollarsQuick reference
- Inbound from internet is free; outbound to internet and cross-Region traffic cost per GB
- Cross-AZ traffic: about 0.01 USD per GB in each direction
- NAT gateway: hourly plus per-GB fee; S3 and DynamoDB gateway endpoints are free
- AWS origin to CloudFront transfer is free; CloudFront egress is usually cheaper
- Every public IPv4 address costs 0.005 USD per hour
- gp3 is about 20 percent cheaper per GB than gp2 with a better baseline
- Lambda: 0.20 USD per million requests plus GB-seconds; free when idle
- Schedule dev environments off outside working hours to save around 70 percent
Common mistakes
- Over-optimizing cost and dropping Multi-AZ when high availability is required.
- Ignoring data transfer when comparing architectures.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Calculate how much a team saves per month by stopping a 0.20 dollar per hour dev instance outside 10 working hours on 5 weekdays.
- Exercise 2medium
Find which EBS volumes in your account are still gp2 and convert one to gp3.
- Exercise 3hard
Schedule a dev Auto Scaling group to scale to zero at 19:00 and back to 2 at 08:00 on weekdays, in your local time zone.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Why is my data transfer bill so high?
- Common causes are traffic through NAT gateways, chatty services talking across AZs, and serving large files directly from EC2 or S3 to the internet. Group by usage type in Cost Explorer to see which one it is.
- Is serverless always cheaper?
- No. It is cheaper for low, spiky or unpredictable traffic because idle time is free. For steady high load, right-sized instances or containers with a Savings Plan are usually cheaper per request.
- Does a stopped EC2 instance cost money?
- You stop paying for the instance hours, but attached EBS volumes, snapshots and any public IPv4 addresses kept on the account still cost money.
- Is Graviton really cheaper?
- Graviton instances usually cost less per hour than similar x86 instances and often perform as well or better. Your software must run on Arm, which most Linux runtimes and containers built for arm64 do.