Cost-Optimized Databases, Networks, and Cost Tools
Module 5 · Design Cost-Optimized Architectures

Cost-Optimized Databases, Networks, and Cost Tools

Design cost-optimized databases and networks: Aurora Serverless and DynamoDB capacity modes, data transfer pricing, NAT gateway and VPC endpoint trade-offs, CloudFront for egress, and the tools that find savings (Cost Explorer, Budgets, tags, Compute Optimizer, Trusted Advisor).

Cost-Optimized Databases

SituationCost-effective choice
Relational, steady loadRDS or Aurora with Reserved Instances for the database instances
Relational, spiky or intermittent loadAurora Serverless v2, which scales capacity in fine-grained steps with demand
Key-value, unpredictable trafficDynamoDB on-demand: pay per request, nothing to size
Key-value, steady and predictable trafficDynamoDB provisioned capacity with auto scaling, plus reserved capacity for the baseline
Data that expiresDynamoDB TTL deletes items for free; S3 lifecycle expiration for objects
Rarely read DynamoDB tablesDynamoDB Standard-IA table class for lower storage cost
Read-heavy load hitting the databaseA cache (ElastiCache, DAX) can be cheaper than scaling the database
Dev and test databasesStop them outside working hours, or use serverless options

Also check backup retention: snapshots kept forever are a slow, silent cost. Set retention to match the actual requirement.


Where Data Transfer Costs Hide

Data transfer is the most surprising line on many AWS bills. The rules that matter most for design (exact prices vary by Region and change over time):

InternetRegionAZ AEC2EC2same AZ, private IP: freeAZ BRDSNAT gateway$/hour + $/GBGateway endpointS3, DynamoDB: freeAmazon S3CloudFrontorigin fetch from AWS: freein: freeout: $/GBcross-AZ: $/GB each wayGreen: no transfer charge. Red: charged. Prices vary by Region; check the current pricing pages.CloudFront egress to users is usually cheaper than serving the same bytes directly from EC2 or S3.

Rules of thumb:

  • Inbound data from the internet is free; outbound to the internet is charged per GB.
  • Traffic between AZs is charged; traffic within one AZ over private IPs is free. Keep chatty components in the same AZ when it doesn’t hurt availability.
  • Traffic between Regions is charged, which matters for cross-Region replication.
  • NAT gateways charge per hour and per GB processed. Sending S3 or DynamoDB traffic through a NAT gateway is a common, avoidable cost. Add gateway endpoints, which are free.
  • One NAT gateway per AZ costs more than one shared NAT gateway, but a shared one adds cross-AZ charges and a single point of failure. The exam usually expects one per AZ when availability matters.
  • CloudFront reduces egress cost and offloads the origin; data from AWS origins to CloudFront isn’t charged.
  • For hybrid connections, Direct Connect has lower per-GB transfer-out rates than the internet, which pays off at high, steady volume.

How many NAT gateways? The cheaper answer and the resilient answer differ:

One shared NAT gatewayInternetAZ ANAT gatewayPrivate EC2AZ BPrivate EC2Lower hourly cost, but cross-AZ chargesAZ A fails → AZ B loses outboundOne NAT gateway per AZInternetAZ ANAT gatewayPrivate EC2AZ BNAT gatewayPrivate EC2Higher hourly cost, no cross-AZ hopSurvives the loss of one AZcross-AZ $
⚠️ Common Pitfall: Optimizing Cost by Breaking a Requirement

Common mistake: choosing a single NAT gateway, a single-AZ database, or S3 One Zone-IA for critical data because it’s the cheapest answer.

If the question says the workload must be highly available or data must survive an AZ failure, those answers are wrong no matter how cheap they are. Cost-optimized means the cheapest design that meets all the requirements.


Tools That Find Savings

ToolWhat it does
AWS Cost ExplorerVisualizes spend and usage over time, forecasts, and recommends Savings Plans and RIs
AWS BudgetsAlerts (and optional actions) when cost, usage, or coverage crosses a threshold
Cost allocation tagsTag resources by team, project, or environment, then activate the tags to see cost by owner
AWS Cost Anomaly DetectionUses machine learning to flag unusual spend
AWS Data Exports (Cost and Usage Report)The most detailed billing data, delivered to S3 for analysis in Athena or BI tools
AWS Compute OptimizerRight-sizing recommendations for EC2, EBS, Lambda, ECS on Fargate, and more
AWS Trusted AdvisorChecks for idle resources, underused instances, and other savings (full checks depend on support plan)
AWS OrganizationsConsolidated billing, so volume discounts and Savings Plans apply across accounts

Key Takeaway

Use Aurora Serverless v2 and DynamoDB on-demand for spiky databases, and reservations for steady ones. Watch data transfer: outbound, cross-AZ, cross-Region, and NAT gateway processing are charged, and gateway endpoints and CloudFront cut them. Track spend with tags, Cost Explorer, and Budgets, and never cut cost by breaking a stated requirement.

🧪 Try It: Find the Hidden Costs

A company’s bill shows high NAT gateway and data transfer charges. Their architecture:

  • Private EC2 instances in two AZs download about 5 TB a month from S3 through a NAT gateway in AZ A only
  • The app tier in AZ A talks constantly to a cache cluster in AZ B
  • Product images are served directly from S3 to users worldwide

List three changes that would reduce cost, and note any availability trade-off.

Suggested answers: add an S3 gateway endpoint (removes NAT processing for S3 traffic); add a NAT gateway in AZ B for availability and to avoid cross-AZ hops; place cache nodes in each AZ and read locally; serve images through CloudFront.

🧠 Knowledge Check

1. A new app has unpredictable traffic that is idle for hours and then spikes. It needs a key-value database. What is the MOST cost-effective choice?

2. Private instances transfer large amounts of data to S3 through a NAT gateway. How can the company reduce cost with the LEAST effort?

3. Finance wants to see AWS cost broken down by project. What should the architect set up?

4. Which of these data transfers is typically FREE?