Mastering Database Capacity Planning: Performance & Provisioning
Database capacity planning (for example, capacity units, instance types, Provisioned IOPS)
Mastering Database Capacity Planning: Performance & Provisioning
Learning Objectives
After studying this guide, you should be able to:
- Differentiate between RDS storage types ( vs. $io1) and their performance characteristics.
- Calculate IOPS requirements based on database page size and desired throughput.
- Provision appropriate Read Capacity Units (RCUs) and Write Capacity Units (WCUs) for DynamoDB tables.
- Select the optimal instance family (Standard, Memory Optimized, Burstable) based on workload patterns.
Key Terms & Glossary
- IOPS (Input/Output Operations Per Second): A performance metric used to measure the speed of storage devices (SSD/HDD).
- RCU (Read Capacity Unit): A DynamoDB metric representing one strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB.
- WCU (Write Capacity Unit): A DynamoDB metric representing one write per second for an item up to 1 KB.
- Throughput: The amount of data moved from one place to another in a given time period (e.g., MiB/s).
- Burst Balance: A credit system for gp2 volumes that allows them to exceed baseline performance for short durations.
The "Big Idea"
Database capacity planning is the art of balancing cost and performance. In the cloud, this isn't a one-time guess but a continuous optimization process. Whether you are provisioning disk speed (IOPS) for a relational database or throughput units for NoSQL, the goal is to ensure the database can handle peak traffic without latency spikes, while avoiding over-provisioning that wastes budget.
Formula / Concept Box
| Concept | Formula / Rule | Notes |
|---|---|---|
| gp2 Baseline IOPS | IOPS_{base} = VolumeSize(GB) \times 3 | Min 100, Max 16,000 |
| io1 Ratio | Storage : IOPS \geq 1:50 | e.g., 100 GB can support up to 5,000 IOPS |
| DynamoDB RCU | \lceil \frac{ItemSize}{4KB} \rceil \times Reads/sec | Divide total by 2 for Eventually Consistent |
| DynamoDB WCU | \lceil \frac{ItemSize}{1KB} \rceil \times Writes/sec | Standard writes consume 1 unit per KB |
| I/O Page Size | \text{If } Page > 32KB \rightarrow \text{Multiple I/Os}$ | 64KB page = 2 I/O operations |
Hierarchical Outline
- I. Amazon RDS Storage Types
- General Purpose SSD (gp2)
- Baseline Performance: 3 IOPS per GB.
- Bursting: Volumes < 1TB can burst to 3,000 IOPS using credits.
- Throughput: Maxes out at 250 MiB/s.
- Provisioned IOPS SSD (io1/io2)
- Consistency: Designed for sub-millisecond latency and consistent I/O.
- Scalability: Up to 256,000 IOPS per volume (engine dependent).
- General Purpose SSD (gp2)
- II. Amazon DynamoDB Capacity
- Provisioned Mode: You specify RCUs and WCUs manually.
- On-Demand Mode: Scales automatically; pay-per-request (best for unpredictable traffic).
- Read Consistency: Strongly Consistent (1 RCU) vs. Eventually Consistent (0.5 RCU).
- III. Database Instance Families
- Standard (m series): Balanced CPU/Memory; general-purpose workloads.
- Memory Optimized (r series): High memory-to-CPU ratio; ideal for large relational DBs.
- Burstable (t series): Low cost; allows CPU bursting for occasional spikes.
Visual Anchors
Decision Flow: RDS Storage Selection
IOPS vs. Storage Volume (gp2)
\begin{tikzpicture}[scale=0.8] \draw[->] (0,0) -- (6,0) node[right] {Storage (GB)}; \draw[->] (0,0) -- (0,5) node[above] {Baseline IOPS}; \draw[thick, blue] (0,0.5) -- (1,0.5) node[right, black, scale=0.7] {100 IOPS (Min)}; \draw[thick, blue] (1,0.5) -- (4,4); \draw[thick, blue] (4,4) -- (5.5,4) node[above, black, scale=0.7] {16,000 Max}; \draw[dashed] (4,0) -- (4,4); \node[below, scale=0.7] at (4,0) {5,334 GB}; \end{tikzpicture}
Definition-Example Pairs
- Strongly Consistent Read: Returns a result that reflects all writes that received a successful response prior to the read.
- Example: A banking application checking a balance immediately after a deposit to ensure the user sees the latest funds.
- Eventually Consistent Read: Response might not reflect the results of a recently completed write; usually reaches consistency within a second.
- Example: A social media feed count where being off by 1 for a few milliseconds doesn't impact user experience.
- Multi-AZ Deployment: Synchronous physical replication of data to a standby instance in a different Availability Zone.
- Example: A production database that must automatically failover if a data center loses power.
Worked Examples
Example 1: RDS gp2 Calculation
Scenario: You have a 500 GB volume. What is the baseline performance, and can it handle a burst of 2,500 IOPS?
- Baseline Calculation: $500 GB \times 3 IOPS/GB = 1,500 IOPS$.
- Burst Capability: Yes. Since the volume is under 1 TB, it can burst up to 3,000 IOPS as long as it has credits in its burst balance.
Example 2: DynamoDB RCU Calculation
Scenario: An application needs to read 10 items per second. Each item is 10 KB. You require Strongly Consistent reads. How many RCUs?
- Size per read: $10 \text{ KB}.
- Units per item: \lceil 10 \text{ KB} / 4 \text{ KB} \rceil = 3 \text{ RCUs}$ per item.
- Total RCUs: $3 RCUs/item \times 10 items/sec = 30 RCUs$.
Checkpoint Questions
- What is the minimum storage size for an RDS instance using $gp2 storage?
- If a database engine uses a 64 KB page size, how many I/O operations does AWS count for a single write?
- True or False: io1$ storage performance depends on the volume size allocated.
- How many WCUs are needed to write 5 items per second, where each item is 1.5 KB?
▶Click to see answers
- 20 GB.
- Two I/O operations (since $64 / 32 = 2$).
- False. In $io1, you provision the IOPS independently of size (within the 50:1 ratio limit).
- 10 WCUs. (Calculation: \lceil 1.5 / 1 \rceil = 2).