AWS Database Cost-Optimization and Selection Guide
Determining cost-effective AWS database services with appropriate use cases (for example, DynamoDB compared with Amazon RDS, serverless)
AWS Database Cost-Optimization and Selection Guide
This guide focuses on the critical architectural decision of selecting the most cost-effective and high-performing database service for specific AWS workloads, a core pillar of the SAA-C03 exam.
Learning Objectives
After studying this guide, you should be able to:
- Distinguish between relational (RDS) and non-relational (DynamoDB) use cases based on cost and access patterns.
- Select the appropriate RDS instance class and storage type (gp3, io1, etc.) for specific performance requirements.
- Calculate DynamoDB throughput costs using Read Capacity Units (RCUs) and Write Capacity Units (WCUs).
- Evaluate the cost-benefits of Aurora Serverless vs. Provisioned instances for unpredictable workloads.
- Identify high-availability (Multi-AZ) vs. read-scaling (Read Replica) configurations and their cost implications.
Key Terms & Glossary
- ACID Compliance: Atomicity, Consistency, Isolation, Durability. Standard for relational databases (RDS/Aurora) ensuring reliable transactions.
- NoSQL: Non-relational database (DynamoDB) that allows for a flexible schema and horizontal scaling.
- Read Capacity Unit (RCU): For DynamoDB, represents one strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB.
- Write Capacity Unit (WCU): For DynamoDB, represents one write per second for an item up to 1 KB.
- Multi-AZ: A high-availability feature that provides a synchronous standby instance in a different Availability Zone.
- Read Replica: An asynchronous copy of the primary database used to offload read traffic; increases cost but improves performance.
The "Big Idea"
In AWS, cost optimization isn't just about picking the cheapest service; it's about matching the database engine to the data access pattern. A "cheap" RDS instance can become incredibly expensive if it requires massive manual scaling or over-provisioned IOPS, whereas a "pricier" Aurora Serverless DB might save thousands by scaling to zero during idle hours. The goal is to minimize "idle capacity" while maintaining required performance and durability.
Formula / Concept Box
| Concept | Calculation/Rule | Cost Impact |
|---|---|---|
| DynamoDB RCU | $1 RCU = 1 Strongly Consistent Read/sec (up to 4KB)$ | 2x cheaper if using Eventually Consistent reads. |
| DynamoDB WCU | $1 \text{ WCU} = 1 \text{ Write/sec (up to 1KB)}$ | Large items (>1KB) consume multiple WCUs. |
| RDS Storage | gp3 (General Purpose) vs io1 (Provisioned IOPS) | gp3 is usually 20% cheaper than gp2 with higher baseline. |
| Licensing | BYOL (Bring Your Own) vs License Included | BYOL can reduce AWS costs if you already own Oracle/SQL Server licenses. |
Hierarchical Outline
- Relational Database Service (RDS)
- Engines: MySQL, PostgreSQL, MariaDB, Oracle, SQL Server, Aurora.
- Scaling: Vertical (Instance size) and Horizontal (Read Replicas).
- Cost Drivers: Instance hours, Storage (GB/month), I/O requests.
- Amazon Aurora
- Architecture: Shared storage layer across 3 AZs.
- Serverless v2: Scales in fine-grained increments; ideal for dev/test or spikey traffic.
- Backtrack: Cost-effective point-in-time recovery without full restores (MySQL only).
- Amazon DynamoDB
- Performance: Single-digit millisecond latency at any scale.
- Capacity Modes: Provisioned (predictable) vs. On-Demand (spikey/unknown).
- Global Tables: Multi-region replication for global low-latency (higher cost).
- Database Migration Service (DMS)
- Homogeneous: Same engine (e.g., Oracle to Oracle).
- Heterogeneous: Different engine (e.g., Oracle to Aurora); uses SCT (Schema Conversion Tool).
Visual Anchors
Database Selection Decision Tree
Multi-AZ vs. Read Replica Architecture
\begin{tikzpicture}[node distance=2cm, every node/.style={rectangle, draw, minimum width=2.5cm, minimum height=1cm, align=center}]
% Multi-AZ side \node (prim) {Primary DB$AZ-A)}; \node (standby) [right of=prim, xshift=2cm] {Standby DB$AZ-B)}; \draw[<->, thick] (prim) -- node[above] {\small Synchronous} (standby); \node[draw=none, fill=none, below of=prim, yshift=1cm] {\textbf{High Availability}};
% Read Replica side \node (master) [below of=prim, yshift=-1cm] {Master DB$AZ-A)}; \node (replica) [right of=master, xshift=2cm] {Read Replica$AZ-B)}; \draw[->, thick, dashed] (master) -- node[above] {\small Asynchronous} (replica); \node[draw=none, fill=none, below of=master, yshift=1cm] {\textbf{Read Scaling}};
\end{tikzpicture}
Definition-Example Pairs
- Relational Database (SQL)
- Definition: A database that stores data in tables with predefined schemas and enforces relationships.
- Example: An ERP system for a manufacturing company where orders, customers, and inventory must maintain strict referential integrity.
- Non-Relational Database (NoSQL)
- Definition: A database that stores data in flexible formats (key-value, document) and scales horizontally.
- Example: A mobile gaming leaderboard that handles millions of small, rapid updates per second with no complex joins required.
- Aurora Serverless
- Definition: An on-demand, auto-scaling configuration for Amazon Aurora.
- Example: A university's student portal that sees massive traffic during registration week but is virtually idle during summer break.
Worked Examples
Example 1: Calculating DynamoDB Throughput Cost
Scenario: An application performs 100 Strongly Consistent Reads per second. Each item is 10 KB.
- Calculate RCU for one item: . We must round up to 3 RCU per item.
- Calculate Total RCU: $100 items/sec \times 3 RCU/item = \mathbf{300 RCU}$.
- Cost Optimization: If we switched to Eventually Consistent reads, we would only need 150 RCU ($300 / 2$), cutting the throughput cost in half.
Example 2: RDS Storage Choice
Scenario: A database requires 10,000 IOPS and 1 TB of storage.
- Option A (gp3): Charges for 1 TB + 7,000 extra IOPS (gp3 provides 3,000 free). This is generally the most cost-effective for medium IOPS needs.
- Option B (io1): Charges for 1 TB + 10,000 Provisioned IOPS. This is much more expensive but provides lower latency and higher consistency for heavy enterprise workloads.
Checkpoint Questions
- Which RDS feature should you use to increase the performance of a read-heavy application without changing the instance size?
- You have a legacy Oracle database and want to move it to Amazon Aurora PostgreSQL. Which tool helps you convert the database schema?
- True or False: A Multi-AZ standby instance can be used to serve read queries to offload the primary instance.
- A startup has an application with unpredictable traffic that completely stops at night. Which database option provides the most cost-savings?
- How many WCUs are required to write 10 items per second, where each item is 2.5 KB?
▶Click to see Answers
- Read Replicas.
- AWS Schema Conversion Tool (SCT).
- False (Only Read Replicas can be read from; Multi-AZ is for failover only).
- Aurora Serverless (it can scale to zero/minimum capacity).
- 30 WCUs ($2.5 KB).