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
| Situation | Cost-effective choice |
|---|---|
| Relational, steady load | RDS or Aurora with Reserved Instances for the database instances |
| Relational, spiky or intermittent load | Aurora Serverless v2, which scales capacity in fine-grained steps with demand |
| Key-value, unpredictable traffic | DynamoDB on-demand: pay per request, nothing to size |
| Key-value, steady and predictable traffic | DynamoDB provisioned capacity with auto scaling, plus reserved capacity for the baseline |
| Data that expires | DynamoDB TTL deletes items for free; S3 lifecycle expiration for objects |
| Rarely read DynamoDB tables | DynamoDB Standard-IA table class for lower storage cost |
| Read-heavy load hitting the database | A cache (ElastiCache, DAX) can be cheaper than scaling the database |
| Dev and test databases | Stop 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):
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:
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
| Tool | What it does |
|---|---|
| AWS Cost Explorer | Visualizes spend and usage over time, forecasts, and recommends Savings Plans and RIs |
| AWS Budgets | Alerts (and optional actions) when cost, usage, or coverage crosses a threshold |
| Cost allocation tags | Tag resources by team, project, or environment, then activate the tags to see cost by owner |
| AWS Cost Anomaly Detection | Uses 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 Optimizer | Right-sizing recommendations for EC2, EBS, Lambda, ECS on Fargate, and more |
| AWS Trusted Advisor | Checks for idle resources, underused instances, and other savings (full checks depend on support plan) |
| AWS Organizations | Consolidated 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.
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.
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?
On-demand capacity charges per request and needs no capacity planning, which suits unpredictable traffic.
2. Private instances transfer large amounts of data to S3 through a NAT gateway. How can the company reduce cost with the LEAST effort?
Gateway endpoints carry S3 traffic privately with no endpoint charge, removing NAT gateway processing fees for that traffic.
3. Finance wants to see AWS cost broken down by project. What should the architect set up?
Activated cost allocation tags let Cost Explorer and billing reports group spend by tag value.
4. Which of these data transfers is typically FREE?
Inbound data transfer from the internet is not charged. Outbound, cross-AZ, and cross-Region transfers are.