5.2.2. Scaling Databases (RDS Read Replicas, DynamoDB)
š” First Principle: Scaling databases involves distributing read workloads (RDS Read Replicas) and dynamically managing throughput (DynamoDB), ensuring consistent performance and responsiveness for data-intensive applications.
Scenario: You are managing a web application with an Amazon RDS for MySQL database that is experiencing high CPU utilization due to frequent reads. You also manage an Amazon DynamoDB table for user profiles that experiences unpredictable traffic spikes.
For SysOps Administrators, scaling databases is crucial for maintaining application performance as data volume and query load increase. Different database types require different scaling strategies.
Key Strategies for Scaling Databases:
- Amazon RDS (Relational Database Service):
- Vertical Scaling: Upgrade the instance type to increase CPU, memory, or storage. This is simple but has physical limits and causes brief downtime.
- Read Replicas: (Asynchronously replicated copies of your primary database instance.) Create one or more Read Replicas to offload read-heavy workloads from the primary database, improving read performance.
- Multi-AZ Deployments: Primarily for high availability, but also aids scaling by removing failover load from the primary instance.
- Amazon DynamoDB (NoSQL Database):
- Automatic Scaling: DynamoDB Auto Scaling automatically adjusts Read Capacity Units (RCUs) and Write Capacity Units (WCUs) to meet actual traffic.
- On-Demand Capacity Mode: Pay-per-request, automatically scales without needing to specify capacity.
- Provisioned Capacity Mode: Specify RCUs/WCUs; optimize with Auto Scaling for predictable workloads.
- Global Tables: For multi-Region, active-active scaling.
ā ļø Common Pitfall: Not separating read and write workloads, leading to the primary database becoming a bottleneck for read-heavy applications.
Key Trade-Offs: Read Replicas (read scaling, eventual consistency) versus primary instance (write scaling, strong consistency). DynamoDB On-Demand (simpler, higher cost for consistent high usage) versus Provisioned (lower cost for predictable usage, but requires management).
Reflection Question: How does scaling databases using Amazon RDS Read Replicas (for relational read scaling) and DynamoDB Auto Scaling (On-Demand or Provisioned Capacity) fundamentally ensure consistent performance and responsiveness for data-intensive applications under varying loads?