Database Capacity Planning: Mastering RCUs, WCUs, and RDS Scaling
Database capacity planning (for example, capacity units)
Database Capacity Planning
This guide covers the essential knowledge required for the SAA-C03 exam regarding database performance and capacity planning, focusing heavily on Amazon DynamoDB throughput and RDS storage optimization.
Learning Objectives
- Calculate Read Capacity Units (RCUs) and Write Capacity Units (WCUs) for DynamoDB based on item size and consistency models.
- Differentiate between relational (RDS) and non-relational (DynamoDB) capacity planning strategies.
- Select appropriate RDS instance classes and storage types (Provisioned IOPS vs. General Purpose).
- Evaluate the impact of read consistency on performance and cost.
Key Terms & Glossary
- RCU (Read Capacity Unit): A measure of throughput in DynamoDB. 1 RCU = 1 strongly consistent read per second for an item up to 4 KB.
- WCU (Write Capacity Unit): A measure of throughput in DynamoDB. 1 WCU = 1 write per second for an item up to 1 KB.
- Strongly Consistent Read: Returns the most up-to-date data by reflecting all successful previous writes. Consumes more RCUs.
- Eventually Consistent Read: Maximizes read throughput but might not reflect a recently completed write. Consumes 50% fewer RCUs than strongly consistent reads.
- Provisioned IOPS (io1/io2): RDS storage designed for I/O intensive workloads, providing low-latency and consistent throughput.
The "Big Idea"
Capacity planning in the cloud shifts from server-based thinking (how much RAM do I need?) to throughput-based thinking (how many operations per second do I need?). For relational databases like RDS, you scale by picking the right instance "size." For NoSQL like DynamoDB, you scale by defining the specific volume of data flowing in and out per second.
Formula / Concept Box
| Operation Type | Item Size Increment | Throughput Equivalent |
|---|---|---|
| Strongly Consistent Read | 4 KB | 1 RCU per second |
| Eventually Consistent Read | 4 KB | 0.5 RCU per second |
| Transactional Read | 4 KB | 2 RCU per second |
| Standard Write | 1 KB | 1 WCU per second |
| Transactional Write | 1 KB | 2 WCU per second |
[!IMPORTANT] Always round up the item size to the next increment (4 KB for reads, 1 KB for writes) before performing the math.
Hierarchical Outline
- DynamoDB Throughput Planning
- Read Capacity (RCU): Depends on consistency and size.
- Write Capacity (WCU): Depends on size (writes are always 1 KB increments).
- RDS Capacity Factors
- Instance Classes: Standard (M), Memory Optimized (R), and Burstable (T).
- Storage Tiers: SSD-backed (gp2/gp3, io1/io2) vs. HDD-backed (st1, sc1).
- Scaling Strategies
- Read Replicas: Offload read traffic from the primary instance.
- RDS Proxy: Efficiently manage high volumes of database connections.
Visual Anchors
DynamoDB Capacity Decision Flow
Visualization of Data Block Units
Definition-Example Pairs
- Bursting (T-Instances): The ability for a database to consume "CPU credits" to handle spikes.
- Example: A small blog that has low daily traffic but spikes when a new post is shared on social media.
- Read Replicas: Asynchronous copies of the primary database.
- Example: A reporting application that runs heavy analytics queries without slowing down the customer-facing checkout database.
- Provisioned IOPS: Storage specifically bought to guarantee a certain number of I/O operations.
- Example: A high-frequency trading platform where every millisecond of database latency translates to lost revenue.
Worked Examples
Example 1: Calculating RCUs
Problem: You need to read 11 KB of data per second using Strongly Consistent reads. How many RCUs do you need?
Solution:
- Take the item size: 11 KB.
- Divide by 4 KB (the RCU increment): $11 / 4 = 2.75$.
- Round up to the nearest whole number: 3.
- Since it is strongly consistent, 1 unit = 1 RCU.
- Answer: 3 RCUs.
Example 2: Calculating WCUs
Problem: You perform 10 writes per second. Each item is 2.5 KB. How many WCUs are required?
Solution:
- Take the item size: 2.5 KB.
- Round up to the nearest 1 KB increment: 3 KB.
- Calculate units per write: $3 KB / 1 KB = 3$ WCUs per write.
- Multiply by operations per second: $3 \times 10 = 30$.
- Answer: 30 WCUs.
Checkpoint Questions
- How many RCUs are consumed by an Eventually Consistent read of a 6 KB item?
- What is the primary difference between RDS Multi-AZ and Read Replicas regarding write replication?
- Which RDS storage type is most cost-effective for large, infrequently accessed sequential data?
- If an item is 3.5 KB, how many WCUs does it consume for a single write?
▶Click to see answers
- 1 RCU. (6 KB rounds up to 8 KB / 4 KB increment = 2. Eventually consistent is 50%, so $2 \times 0.5 = 1$).
- Multi-AZ uses synchronous replication (high availability); Read Replicas use asynchronous replication (scaling).
- st1 (Throughput Optimized HDD).
- 4 WCUs. (3.5 KB rounds up to 4 KB. 1 WCU per 1 KB).