In scenarios with a high volume of read requests and a low number of write requests, a single instance may struggle with read demand. Creating one or more read-only instances can distribute the database load, satisfy the high read demand, and enhance the application's throughput.
Introduction
A read-only instance is generated by copying data from the primary instance, ensuring consistency. Data updates on the primary instance are automatically synchronized to all read-only instances.
-
You can create up to 5 read-only instances if the primary instance uses local disks, and up to 32 if it uses cloud disks.
-
Read-only RDS instances associated with a primary instance using local disks operate within a high-availability architecture.
-
For primary RDS instances with cloud disks, read-only instances function in a standalone architecture without a secondary node, which does not guarantee availability. It is advisable to acquire multiple read-only instances and employ libpq or JDBC for automatic failover. For more information, see automatic failover and read/write splitting. Automatic read/write splitting can also be achieved through a database proxy. For more information, see what is a database proxy.
The diagram below illustrates the topology of the primary RDS instance and its read-only RDS instances.
Scenarios
-
Create read-only instances to redirect read requests and alleviate the load on the primary instance when it is under high demand.
-
During backup or maintenance, when the primary instance is temporarily unavailable, read-only instances can handle read requests to maintain service continuity.
-
For tasks like report analysis, read-only instances can process query analysis on large datasets without impacting the primary instance.
-
In read/write splitting scenarios, read-only instances help avoid contention issues and boost system performance and throughput.
Billing
Read-only RDS instances are available with subscription or pay-as-you-go billing options. Subscription rates are available on the purchase page. For pay-as-you-go rates, refer to the read-only instance specifications list.
Features
-
Regions and zones: Read-only RDS instances are located in the same region as the primary instance but may be in different zones.
-
Change network type: This can differ from the primary instance.
-
Account and database management: Accounts and databases on read-only instances are synchronized from the primary instance, eliminating the need for separate management.
-
Whitelist: Read-only instances inherit the whitelist settings from the primary instance, but they can be managed independently. To modify a read-only instance's whitelist, see set whitelist.
-
Monitoring and alerting: Performance metrics for read-only instances, including disk usage, IOPS, connection count, and CPU utilization, are available in chart form.
-
Read/write splitting: This feature, combined with the database proxy, directs write requests to the primary RDS instance and read requests to read-only instances, reducing the load on the primary instance. To enable the database proxy for the primary instance, see what is a database proxy.
-
Read-only RDS instances: Up to 5 can be created for primary instances with local disks, and up to 32 for those with cloud disks.
Precautions
-
Instance backup: Backups for read-only RDS instances cannot be configured or created manually; these are managed at the primary instance level.
-
Data migration: Data cannot be migrated to read-only RDS instances.
-
Database management: Creation or deletion of databases on read-only instances is not permitted.
-
Account management: Account creation, deletion, permission granting, and password changes are not allowed on read-only instances.
-
Specifications and storage capacity:
-
Cloud disks: The storage capacity of a read-only instance must not be less than that of the primary instance. If the primary instance's memory exceeds that of the read-only instance, an upgrade to the primary instance will trigger a restart of the read-only instance.
-
Local disks: The specifications and storage capacity of a read-only instance must match or exceed those of the primary instance.
-
-
In the event of unexpected errors, such as replication failures of database engine settings, ApsaraDB RDS will rebuild the affected read-only RDS instance.
-
Upon release of the primary RDS instance, subscription-based read-only instances are automatically refunded and released, while pay-as-you-go read-only instances are directly released.