To handle high read concurrency and improve overall system throughput, you can create a read-only instance for efficient read/write splitting. A read-only instance is a full replica of the primary instance. Any data changes on the primary instance are automatically synchronized to all associated read-only instances. This offloads the read workload from the primary instance and ensures that data on the read-only instances remains consistent with the primary instance.
To create read-only instances for other database engines, see the following topics:
Prerequisites
The primary RDS for MySQL instance must meet the following conditions:
-
The RDS instance runs MySQL 8.0, MySQL 5.7, or MySQL 5.6.
-
The RDS instance uses the subscription or pay-as-you-go billing method. Serverless RDS instances do not support read-only RDS instances.
-
The RDS instance runs RDS High-availability Edition.
-
You can go to the Basic Information page of your RDS instance to obtain the preceding information.
-
You can create read-only RDS instances that run RDS High-availability Edition or RDS Basic Edition. A read-only RDS instance that runs RDS High-availability Edition includes a primary instance and a secondary instance that work in HA mode. For more information, see RDS High-availability Edition.
Usage notes
-
You can create a read-only instance only from a primary instance. You cannot convert an existing instance into a read-only instance.
-
Creating a read-only instance does not affect the primary instance because data is replicated from the primary instance's secondary node.
-
If the primary instance is released, Subscription read-only instances are automatically refunded and released, while Pay-As-You-Go read-only instances are immediately released.
-
A read-only instance does not inherit the parameter settings of its primary instance. The read-only instance is created with default parameter values, which you can then modify in the instance's console.
-
The storage type of the read-only instance must be the same as the primary instance's.
-
Backups are performed on the primary instance. Therefore, a read-only instance supports only local log retention policies. You cannot configure automatic backup policies or initiate manual backups for a read-only instance.
-
Storage space:
-
Cloud disk-based instances: The storage space of a read-only instance cannot be smaller than that of its primary instance. If the memory of the primary instance is larger than that of the read-only instance, changing the primary instance's specifications restarts the read-only instance.
-
Local disk-based instances: The storage space of a read-only instance cannot be smaller than its primary instance's.
-
-
You can create a maximum of 10 read-only instances.
-
Billing method: Subscription or Pay-As-You-Go. For pricing details, see Read-only instance types.
-
The VPCs that you can select when you create a read-only instance are subject to limitations.
Procedure
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
-
On the Basic Information page, in the Instance Distribution section, click Add to the right of Read-only Instance.
NoteIf the Add button is not displayed, check whether the instance meets the prerequisites.
-
Configure the basic resources for the read-only instance.
Parameter
Description
Billing Method
-
Subscription : You pay for resources in advance. This billing method is ideal for long-term use and is more cost-effective than Pay-As-You-Go. The longer the subscription, the greater the discount.
-
Pay-As-You-Go: You are charged for resources by the hour. This billing method is suitable for short-term use, and you can release the instance at any time to save costs.
Edition
-
Basic Edition: A cost-effective, single-node read-only instance ideal for learning or testing. Recovery from a fault or restart is slow.
NoteThis option is available only when the storage type of the primary instance is cloud disk.
-
High-availability Edition (Default): Ensures high availability with a primary and a secondary node. This edition is recommended for production environments.
NoteIf you select High-availability Edition, you must also configure the zone for the primary node, the deployment method (multi-zone deployment or single-zone deployment), and the zone for the secondary node.
Product Type
You can select the Yitian edition only if the Storage Type of the primary instance is Enhanced SSD, .
For more information about the Standard Edition and YiTian editions, see Product types.
Zone
This parameter applies only to Basic Edition read-only instances. A zone is an independent physical area within a region. An instance of the Basic Edition is a single-node instance and uses a single-zone deployment by default.
-
Zone of Primary Node
-
Deployment Method
-
Zone of Secondary Node
This parameter applies only to High-availability Edition read-only instances. A zone is an independent physical area within a region. For an instance of the High-availability Edition, you must also select a deployment method:
-
Single-zone Deployment: The primary and secondary nodes are in the same zone. You need to specify only the zone of the primary node.
-
Multi-zone Deployment: The primary and secondary nodes are in different zones. This method provides cross-zone disaster recovery at no extra charge. You need to specify the zones of the primary and secondary nodes.
Instance Type
-
General-purpose: A general-purpose instance has dedicated memory and I/O resources but shares CPU and storage with other instances on the same server.
-
Dedicated: An instance of a dedicated instance type exclusively uses its allocated CPU, memory, storage, and I/O resources. An instance of an exclusive instance type exclusively uses all the CPU, memory, storage, and I/O resources on its host server.
NoteEach instance type has a specific number of CPU cores, memory capacity, maximum number of connections, and maximum IOPS.
Database Proxy
If a database proxy is not enabled for the primary instance, you can enable the free general-purpose database proxy when you create a read-only instance. The system automatically deploys the proxy based on the recommended specifications and enables the database proxy feature for the primary instance. A database proxy provides advanced features, such as read/write splitting, connection pooling, transaction splitting, persistent connections, and Secure Sockets Layer (SSL) encryption. After you enable the database proxy, you can change the proxy type and specifications or manually disable the database proxy based on your business requirements.
Note-
If the database proxy is enabled for the primary instance, the database proxy feature is enabled for the read-only instance by default. You do not need to manually enable the feature.
-
You can also enable the database proxy after the read-only instance is created.
Capacity
The storage space includes data space, system file space, log file space, and transaction file space. The minimum increment for adjusting storage space is 5 GB.
NoteThe storage space of a read-only instance must be greater than or equal to that of its primary instance.
-
-
Click Next: Instance Configuration and configure other instance parameters.
Parameter
Description
VPC
By default, the read-only instance uses the same VPC as the primary instance. This parameter is not configurable.
VSwitch of Primary Node
You can select a VSwitch for the primary node or use the default one.
VSwitch of Secondary Node
A VSwitch is automatically allocated for the secondary node. This parameter is not configurable.
Port
The default is port 3306. You can change this value.
Release Protection
This parameter applies only to Pay-As-You-Go instances. Enable release protection to prevent accidental release of a Pay-As-You-Go instance.
Resource Group
By default, the read-only instance is in the same resource group as the primary instance. This parameter is not configurable.
Instance Name
Optional. Specify a custom name to help you identify the instance.
Tags
If you have a large number of instances, you can add tags to them for categorization and management. This parameter is optional.
-
Click Next: Confirm Order, confirm the Parameter Configuration, select Quantity, and Duration (for Subscription instances only), and then click Pay Now to complete the payment.
Note-
If the primary instance is a Subscription instance, you can select the Consistent with Primary Instance checkbox next to Duration when you purchase a Subscription read-only instance. This aligns the read-only instance's lifecycle with the primary instance's.
-
If the primary instance is a Subscription instance and you change the billing method of a read-only instance from Pay-As-You-Go to Subscription, you cannot select Consistent with Primary Instance for Duration. This setting is available only for newly purchased read-only instances. To use this alignment option, we recommend that you release the Pay-As-You-Go read-only instance and then purchase a new Subscription one.
-
For Subscription instances, we recommend that you select Auto-renewal. This prevents service interruptions from overdue payments and removes the need for manual renewal.
-
View the read-only instance and its endpoint
-
Log on to the ApsaraDB RDS console. In the navigation pane on the left, click Instances. In the top navigation bar, select a region.
-
In the instance list, find the primary instance and click the arrow on the left of the instance ID to view the read-only instances associated with it.

You can also click the ID of the primary instance to go to its details page. The read-only instances are displayed in the section.

-
View the endpoint of the read-only instance: Each read-only instance has a dedicated endpoint. To obtain the endpoint, click the ID of the read-only instance to go to its details page. Then, in the section, click View Details.

Replication delay
A replication delay may occur when a read-only instance synchronizes data from its primary instance. You can view the delay on the Basic Information page of the read-only instance. For information about the common causes of and solutions for replication delays, see Causes of and solutions for the replication latency of an ApsaraDB RDS for MySQL read-only instance.
Configure read/write splitting
After you add a read-only instance, you can manually configure read/write splitting in your application or enable the database proxy feature to automatically handle read/write splitting. For more information, see What is a database proxy?, What is read/write splitting?, and Enable the database proxy feature.
The general-purpose database proxy and persistent connection features are free of charge. For more information, see ApsaraDB RDS for MySQL instances support the free-of-charge general-purpose database proxy and persistent connection features.
Take a read-only instance offline
Assume that you have a read/write splitting environment with one primary instance and two read-only instances: primary instance A, and read-only instances B and C. To take read-only instance C offline without service interruption, perform the following steps.
-
Go to the RDS Instances page, select the region, and then click the ID of instance A.
-
In the left-side navigation pane, click Database Proxy. In the Connection Topology Management section, click Modify Configuration.

-
In the Modify Proxy Endpoint (Terminal) Configuration dialog box, set the read weight of read-only instance C to 0.

-
Go to the Monitoring and Alerts page of read-only instance C. In the Session Connection monitoring metrics, observe the active_session metric and wait for it to drop to 0.
NoteYou only need to check whether the active_session value is 0. If it does not drop to 0 after an extended period, you can kill the session.
-
On the Database Proxy tab of primary instance A, remove read-only instance C from the database proxy endpoint.
FAQ
Creation
-
Q: Why can't I select a specific zone when I create a read-only instance?
A: If a zone is unavailable for selection, it indicates that resources are sold out in that zone. You can select another zone. This does not affect the read-only instance.
-
Q: Can I select a VPC for the read-only instance that is different from the VPC of the primary instance?
A:
-
If the primary instance resides in the classic network, you can select any VPC for the read-only instance.
-
If the primary instance resides in a VPC, the options for the read-only instance's VPC are as follows:
-
If the storage type is local SSD, you can select any VPC for the read-only instance.
-
If the storage type is cloud disk, the read-only instance must reside in the same VPC as the primary instance.
-
-
-
Q: Does creating a read-only instance affect the primary instance?
A: During the creation process, you cannot perform operations such as changing the specifications of the primary instance. Wait until the read-only instance is created to perform these operations. The primary instance is otherwise unaffected.
-
Q: Can I add a read-only instance to an ApsaraDB RDS for MySQL instance of the Basic Edition to implement read/write splitting?
A: You cannot directly add a read-only instance to an ApsaraDB RDS for MySQL instance of the Basic Edition. You can upgrade an ApsaraDB RDS for MySQL 8.0 or 5.7 instance from Basic Edition to High-availability Edition, add a read-only instance, and then enable and configure the database proxy feature to implement read/write splitting. You can also upgrade the Basic Edition instance to the Cluster Edition and use the primary and secondary nodes of the Cluster Edition instance to implement read/write splitting.
-
For information about how to upgrade an instance from Basic Edition to High-availability Edition, see Upgrade an ApsaraDB RDS for MySQL instance from Basic Edition to High-availability Edition.
-
For information about how to upgrade an instance from Basic Edition to Cluster Edition, see Upgrade an ApsaraDB RDS for MySQL instance from Basic Edition to Cluster Edition.
-
For information about how to enable and configure the database proxy feature, see Enable the database proxy feature and Configure an access policy for a database proxy endpoint.
-
-
Q: Can I select zones for the primary and secondary nodes when I create a read-only instance of the High-availability Edition?
A: You can select zones for the primary and secondary nodes only if the primary instance uses cloud disks and its minor engine version is 20210430 or later. In other cases, you cannot select zones for the primary and secondary nodes.
Synchronization and delay
-
Q: How long does data synchronization for a read-only instance take?
A: Under normal circumstances, data is synchronized in real time. However, a replication delay may occur during large transactions or DDL operations. The actual delay varies based on the specific circumstances.
-
Q: How can I determine whether replication is normal based on the replication delay of a read-only instance?
A: Typically, the replication delay of a read-only instance is within 1 second. If the delay exceeds 1 second, a data synchronization delay occurs. In extreme cases, the connection may be interrupted.
-
Q: What are the common causes of replication delays?
A: For information about the common causes of and solutions for replication delays, see Causes of and solutions for the replication latency of an ApsaraDB RDS for MySQL read-only instance.
-
Q: Do read-only instances support parallel replication?
A: Yes, read-only instances support parallel replication.
Connection and routing
-
Q: How do I force requests to be processed by the primary instance?
A: You can use one of the following methods to force requests to be sent to the primary instance:
-
Connect to the internal or public endpoint of the primary instance to send requests directly to the primary instance.
-
If the database proxy is enabled and transaction splitting is disabled, you can encapsulate requests within a transaction. By default, operations within a transaction are sent to the primary instance.
-
Use hints to route requests to the primary instance. For more information, see Hints.
-
-
Q: Does a read-only instance have a dedicated endpoint? Can I connect to a read-only instance by using the dedicated endpoint?
A: Yes, a read-only instance has a dedicated endpoint. You can obtain the endpoint in the Basic Information section on the details page of the read-only instance.
Instance maintenance
-
Q: I added a read-only instance to my ApsaraDB RDS for MySQL instance, and after a while, its storage usage is higher than the primary instance's. Is this normal?
A: Yes, this is normal. This space discrepancy is caused by differences in the data synchronization mechanism between the primary and read-only instances:
-
Primary instance: Executes original SQL statements, such as
INSERTandUPDATE. -
Read-only instance: Replays row-based binary log events to synchronize data.
This difference in the InnoDB page writing mechanism may cause page splits or more internal storage fragmentation on the read-only instance. Therefore, even if the data is completely consistent, the physical files of the read-only instance may be larger than those of the primary instance. In scenarios that involve frequent updates, deletions, or large transactions, the ibdata1 file, undo log, or temporary files of the read-only instance may grow faster, making the space difference more significant.
Solution: Recreate the read-only instance. After you enable read/write splitting by using a database proxy, create a new read-only instance. After the new instance is running as expected, delete the old instance.
-
-
Q: If a read-only instance is of the High-availability Edition and has primary and secondary nodes, how do I configure parameters for these two nodes?
A: You need to configure parameters only on the primary node of the read-only instance. The secondary node automatically synchronizes the parameter settings from the primary node. You cannot directly modify the parameters of the secondary node.
-
Q: Can a read-only instance be converted into a regular instance?
A: No, this is not supported.
-
Q: Can I back up the data of a read-only instance? Can automatic instance backups be performed on the read-only instance?
A: You do not need to back up the data of the read-only instance. Backups are performed on the primary instance. Because snapshot backups are used, they do not affect the primary instance's performance.
-
Q: How are transaction logs cleared?
A: The local logs of an ApsaraDB RDS for MySQL instance are automatically deleted based on rules or can be manually deleted.
-
Q: Does changing the configuration, releasing, or changing the billing method of a read-only instance affect the primary instance?
A: No.
Billing
-
Q: Can the billing method of a read-only instance be changed?
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: How do I estimate the costs of a read-only instance?
A: Log on to the ApsaraDB RDS console, go to the page for creating a read-only instance, and configure parameters such as the instance type and storage space based on your business requirements. The fees that are displayed on the page can be used as a cost estimate.
API reference
|
API |
Description |
|
Creates a read-only ApsaraDB RDS instance. |