AWS RDS: Configuring Read Replicas to Meet Business Requirements
Configuring read replicas to meet business requirements
AWS RDS: Configuring Read Replicas to Meet Business Requirements
Learning Objectives
After studying this guide, you should be able to:
- Distinguish between Vertical Scaling (scaling up) and Horizontal Scaling (scaling out).
- Configure and deploy Amazon RDS Read Replicas for various database engines.
- Understand the constraints of asynchronous replication and its impact on RPO (Recovery Point Objective).
- Design architectures that offload read-heavy workloads and reporting/analytics traffic.
- Execute the promotion of a Read Replica to a standalone Master instance.
Key Terms & Glossary
- Horizontal Scaling (Scaling Out): Adding more instances (Read Replicas) to handle increased load, rather than increasing the size of a single instance.
- Asynchronous Replication: A data-syncing method where the master database does not wait for the replica to acknowledge receipt of data. This introduces a "replication lag."
- Read-only Endpoint: A specific DNS entry provided by AWS that routes traffic exclusively to read replicas to offload the primary database.
- Promotion: The process of converting a Read Replica into a standalone, primary database instance capable of both reads and writes.
- Aurora Replica: A specialized type of replica exclusive to Amazon Aurora that supports up to 15 replicas with much lower latency.
The "Big Idea"
In modern cloud architectures, the primary database (Master) is often the bottleneck due to write-heavy transactions. Read Replicas allow you to decouple the "read" traffic from the "write" traffic. By offloading queries, reporting, and analytics to replicas, you ensure the primary database remains responsive for critical application updates, effectively allowing the database tier to scale horizontally.
Formula / Concept Box
| Feature | Multi-AZ (High Availability) | Read Replicas (Scalability) |
|---|---|---|
| Primary Purpose | High Availability / Disaster Recovery | Performance / Scaling Read Traffic |
| Replication Type | Synchronous | Asynchronous |
| Active/Passive | One active (Primary), one passive (Standby) | All replicas are active for Read queries |
| Automatic Failover | Yes | No (requires manual promotion) |
| Endpoint | Single DNS endpoint (points to Primary) | Separate Read-only endpoints per replica |
Hierarchical Outline
- I. Database Scaling Strategies
- Vertical Scaling (Up): Upgrading instance class (CPU, RAM). Requires downtime (except for Aurora).
- Horizontal Scaling (Out): Adding Read Replicas. No application downtime for the master.
- II. Read Replica Fundamentals
- Limits: Up to 5 for standard RDS; up to 15 for Amazon Aurora.
- Supported Engines: MySQL, MariaDB, PostgreSQL, Oracle, SQL Server (Enterprise).
- Connectivity: AWS provides a unique DNS endpoint for each replica.
- III. Operational Workflows
- Creation: Can be created from existing instances via the RDS Console or CLI.
- Cross-Region: Replicas can exist in different AZs or entirely different AWS Regions for global performance.
- Promotion: Used for DR or when transitioning a replica to a new master instance.
Visual Anchors
Read Traffic Flow
Cross-Region Replication Architecture
\begin{tikzpicture} \draw[thick, dashed] (0,0) rectangle (4,4) node[pos=0.5, above=1.5cm] {Region: us-east-1 (Primary)}; \draw[thick, dashed] (6,0) rectangle (10,4) node[pos=0.5, above=1.5cm] {Region: eu-west-1 (Secondary)};
% Primary DB
\node[draw, cylinder, cylinder uses custom fill, cylinder fill=blue!20, shape border rotate=90, minimum width=1cm, minimum height=1.2cm] (M) at (2,2) {Master};
% Local Replica
\node[draw, cylinder, cylinder uses custom fill, cylinder fill=green!20, shape border rotate=90, minimum width=1cm, minimum height=1.2cm] (R1) at (2,0.5) {Replica A};
% Remote Replica
\node[draw, cylinder, cylinder uses custom fill, cylinder fill=green!20, shape border rotate=90, minimum width=1cm, minimum height=1.2cm] (R2) at (8,2) {Replica B};
% Replication arrows
\draw[->, thick, blue] (M) -- (R1) node[midway, right] {Async};
\draw[->, thick, red] (M) -- (R2) node[midway, above] {Cross-Region Sync};\end{tikzpicture}
Definition-Example Pairs
- Read-Heavy Workload: An application that performs many more
SELECToperations thanINSERT/UPDATE/DELETE.- Example: A news website where thousands of users read articles (reads), while only a few editors publish content (writes).
- Replication Lag: The time difference between a transaction being committed on the master and appearing on the replica.
- Example: A user updates their profile picture, but when they refresh immediately, the old picture still shows because the replica used for the refresh hasn't received the update yet.
- Manual Promotion: The administrative act of disconnecting a replica from its master to make it a standalone DB.
- Example: During a regional disaster, an admin promotes an eu-west-1 replica to master so European users can continue writing data.
Worked Examples
Example 1: Creating a Read Replica (Console Path)
- Navigate to the RDS Service in the AWS Management Console.
- Select the source database instance (e.g.,
production-db). - Click Actions > Create Read Replica.
- Configure Settings: Provide a unique DB instance identifier (e.g.,
production-db-replica-1). - Placement: Choose a destination region and AZ. (Note: Using a different AZ increases availability).
- Launch: Click "Create Read Replica." RDS will take a snapshot of the master and provision the new instance.
Example 2: Promoting a Replica for Disaster Recovery
Scenario: The Master instance in us-east-1 has become corrupted. You need to enable writes on your replica in us-east-2 immediately.
- Select the replica instance in the RDS dashboard.
- Click Actions > Promote.
- Confirm: Review the backup settings for the new master.
- Execute: Click "Promote Read Replica."
- Update Application: Change your application's database connection string from the old master endpoint to the new endpoint of the promoted instance.
[!WARNING] Data written to the original master just before failure may be lost during promotion due to the asynchronous nature of the replication.
Checkpoint Questions
- What is the maximum number of Read Replicas allowed for a standard RDS MySQL instance? (Answer: 5)
- Does Amazon RDS support automatic failover to a Read Replica if the master fails? (Answer: No, that is the role of Multi-AZ. Read Replicas require manual promotion.)
- Which database engine is unique in that its replicas use a shared storage volume and support up to 15 replicas? (Answer: Amazon Aurora)
- Why would a business point their "Monthly Sales Report" tool to a Read-only Endpoint instead of the Master? (Answer: To prevent complex, resource-intensive analytical queries from slowing down live customer transactions on the Master.)
- True or False: You can create a Read Replica in a different AWS Region than the source database. (Answer: True)