A read replica is a secondary database instance created from a snapshot of a primary database, primarily used to manage read-heavy workloads. It serves as a read-only database instance. For example Amazon RDS employs the database engine's native replication feature to maintain synchronization with the primary database.
This setup helps in scaling out database capabilities beyond a single instance's limitations by distributing the read traffic, which in turn enhances the primary database's performance for write operations.
What are the use cases for read replicas in AWS
Read replicas in AWS serve multiple roles in enhancing database performance and availability.
They key use cases include:
Scaling for Read-Heavy Workloads
They distribute read traffic across multiple instances, effectively managing workloads that exceed the capacity of a single database instance. This distribution improves overall performance.
Continuity During Downtime
Read replicas ensure that read operations continue seamlessly during periods when the source database undergoes maintenance, backups, or faces failures.
Disaster Recovery (DR)
In the event of a primary database failure, read replicas can be promoted to standalone instances. This capability is particularly useful for failover to a replica in a different region, contributing to an effective DR strategy.
Reporting and Data Warehousing
For intensive data queries, such as those needed in business reporting and analytics, read replicas offload the workload from the production database, ensuring it remains focused on critical operations.
Application Compatibility and Scalability
The use of read replicas requires no modification to application code, as they connect via the database endpoint. Amazon RDS automates replication, allowing for scalability of read throughput as soon as replicas are set up. Best practices include distributing read loads, conducting read-only transactions, and using a load balancer.
Geographic Distribution
By situating read replicas in various regions, they can serve users with lower latency, based on geographic proximity.
Database Testing and Upgrades
Testing updates or changes on a read replica before applying them to the primary database minimizes risk to the production environment.
Backup Offloading
Performing backups on a read replica alleviates performance impacts on the primary database.
It's important to consider factors such as replication lag, costs, and data consistency when implementing read replicas. Replication lag must be minimal for effectiveness, and while they enhance performance and availability, they also add costs for data transfer and storage.
What AWS services offer read replicas?
AWS offers read replica functionality in several of its services to enhance performance, scalability, and availability for different types of database workloads. Different AWS services utilizes read replicas to address specific use cases, ranging from improving read performance in relational databases to ensuring high availability and fault tolerance in distributed database systems.
Key services include:
Amazon RDS
Service supports read replicas for a variety of database engines such as MySQL, MariaDB, PostgreSQL, Oracle, and SQL Server. Amazon RDS enables the creation of one or more read-only copies of a database instance. These replicas can be located within the same region or across different regions, primarily serving read-heavy database workloads by distributing read queries to improve throughput.
Amazon Aurora
As an extension of Amazon RDS, Aurora offers advanced read replica features. It allows up to 15 read replicas with minimal replication lag and automatic data replication across multiple Availability Zones. Aurora is optimized for high-throughput, read-heavy workloads.
Amazon ElastiCache for Redis
Although not a conventional database, ElastiCache supports read replicas. This service is used for scaling out read performance and ensuring high availability. It manages the replication process and facilitates failover to replicas if the primary node fails.
Amazon Neptune
Neptune, a graph database service, also provides read replica capabilities. It supports up to 15 read replicas, with asynchronous updates visible to replicas within milliseconds. In case of primary failure, a read replica can be automatically promoted to a primary instance. Neptune uses the same underlying storage as the primary, ensuring data consistency and high availability for graph traversal and other highly connected data queries.
Amazon DocumentDB
DocumentDB supports read replicas, enhancing scalability and performance for MongoDB-compatible workloads.
Additionally, Amazon DynamoDB offers a similar concept through its global tables feature, enabling the creation of table replicas in different regions for disaster recovery and latency reduction. These replicas are automatically synchronized with the primary table.
References
Working with DB instance read replicas - Amazon Relational Database Service
RDS READ REPLICAS GENERAL QUESTION
Working with DB instance read replicas - Amazon Relational Database Service
Amazon RDS Read Replicas | Cloud Relational Database | Amazon Web Services
Database Cloning in Neptune - Amazon Neptune
Amazon DocumentDB: How It Works - Amazon DocumentDB
Managed Cloud Database -- Amazon DocumentDB (with MongoDB compatibility) FAQs -- Amazon Web Services