Create one or more read-only RDS instances to offload read traffic from the primary instance, increasing read throughput for read-heavy workloads.
Overview
When you create a read-only RDS instance, data is replicated from the secondary instance without interrupting primary instance workloads. Updates on the primary instance are automatically synchronized to all read-only instances.
-
Primary instances with Premium Local SSDs support up to 5 read-only instances. Primary instances with cloud disks support up to 32.
-
Read-only instances on Premium Local SSDs use a high-availability architecture.
-
Read-only instances on cloud disks use a single-node architecture with no standby nodes. To ensure availability, purchase multiple read-only instances and use libpq or JDBC for automatic failovers. For more information, see Implement automatic failover and read/write splitting. You can also use the database proxy feature for automatic read/write splitting. For more information, see What are database proxies?
The following figure shows the topology between the primary instance and its read-only instances.
Scenarios
-
The primary instance is overloaded with read requests. Create read-only instances to offload read traffic.
-
The primary instance is temporarily unavailable due to backup or maintenance. Read-only instances continue serving read requests to ensure business continuity.
-
Run data analysis and reporting queries on read-only instances without affecting primary instance performance.
-
Use read/write splitting to eliminate lock contention and improve system throughput.
Billing rules
Read-only RDS instances support subscription and pay-as-you-go billing. For subscription pricing, visit the ApsaraDB RDS buy page. For more information about the fee for a pay-as-you-go read-only RDS instance, see Read-only instance types.
Features
-
Regions and zones: Read-only instances must be in the same region as the primary instance but can be in different zones.
-
Network type: Read-only instances can use a different network type from the primary instance. For more information, see Change the network type.
-
Account and database management: Accounts and databases are automatically synchronized from the primary instance. No separate management is required on read-only instances.
-
IP address whitelists: The system replicates IP address whitelists from the primary instance when a read-only instance is created. After creation, whitelists are managed independently. To modify a read-only instance's whitelists, follow the instructions provided in Configure an IP whitelist.
-
Monitoring and alerting: Monitor performance metrics such as disk usage, IOPS, connections, and CPU utilization through charts.
-
Read/write splitting: The database proxy feature forwards write requests to the primary instance and read requests to read-only instances. For more information about how to enable the database proxy feature for a primary RDS instance, see What are database proxies?
-
Instance limits: Up to 32 read-only instances for primary instances with cloud disks, or up to 5 for Premium Local SSDs.
Limits
-
Data backup: Backup policies and manual backups are configured only on the primary instance, not on read-only instances.
-
Data migration: You cannot migrate data to read-only instances.
-
Database management: You cannot create or delete databases.
-
Account management: You cannot create accounts, grant permissions, change passwords, or delete accounts on read-only instances.
-
Specifications and storage capacity:
-
For cloud disk instances: read-only instance storage must be greater than or equal to the primary instance storage. If the primary instance has more memory than a read-only instance, the read-only instance restarts during specification changes.
-
For Premium Local SSD instances: read-only instance specifications and storage cannot be lower than the primary instance.
-
-
If a read-only instance encounters unexpected errors such as replication failures, the system automatically rebuilds it.
-
When the primary instance is released, subscription read-only instances are automatically refunded and released, and pay-as-you-go read-only instances are directly released.
FAQ
Q: Can I change the billing method of a read-only instance?
A: Yes. For more information, see Change the billing method of an instance from pay-as-you-go to subscription or Change the billing method of an instance from subscription to pay-as-you-go.
Q: Does changing the configurations, releasing, or changing the billing method of a read-only instance affect the primary instance?
A: No, these actions do not affect the primary instance.
Q: Can I use the accounts created on the primary instance to access the read-only instance?
A: Yes. Accounts from the primary instance are synchronized to the read-only instance but cannot be managed there. These accounts have read-only permissions on the read-only instance.
Q: Can I convert a read-only instance into a regular instance, for example, for disaster recovery?
A: No, this is not supported.
Q: Can I back up data on a read-only instance? Can automatic backups be performed on the read-only instance?
A: No. Backups are not required for read-only instances. All backups are performed on the primary instance.
Q: Does the read-only instance support parallel replication?
A: ApsaraDB RDS for PostgreSQL uses physical streaming replication, which relies on WAL log synchronization and replay to replicate data. This method is highly efficient and does not require parallel replication.
Q: How are transaction logs cleared?
A: After an ApsaraDB RDS for PostgreSQL WAL log backup is complete, the kernel automatically clears the logs during a checkpoint operation.
Q: How can I determine if replication is normal based on the replication latency?
A: Normally, replication latency is under one second. Latency greater than one second indicates a data synchronization delay. In extreme cases, the replication may be disconnected.
Q: What are the common causes of replication latency?
A: The common causes and their solutions are as follows:
Cause 1: The read-only instance has significantly lower specifications than the primary instance, which can cause high replication latency.
Solution: Upgrade the read-only instance's instance type. For more information, see Change instance specifications.
Cause 2: The
max_standby_streaming_delayparameter is not configured properly, which causes high replication latency. For information about how to set parameters, see Modify the parameters of an ApsaraDB RDS for PostgreSQL instance.Solution: Adjust the value of the
max_standby_streaming_delayparameter:A small value reduces replication latency between the read-only instance and the primary instance, but may cause transactions on the read-only instance to be canceled.
An excessively large value may cause high replication latency.