RDS for SQL Server allows you to manage read-only instances and provides a unified read-only routing endpoint to implement read/write splitting. By configuring the primary instance endpoint and the read-only routing endpoint in your application, you can improve system performance, enhance scalability, and achieve load balancing for read operations. In addition, RDS for SQL Server on RDS Cluster Edition provides a secondary instance endpoint. You can use this endpoint to connect to the secondary instance for troubleshooting, data verification, and other operational tasks.
How it works
After you create read-only instances for your RDS for SQL Server primary instance, you can enable read/write splitting. By configuring the primary instance endpoint and the read-only routing endpoint in your application, write requests are sent to the primary instance, and read requests are sent to the read-only routing endpoint. The read-only routing endpoint then automatically distributes the read requests among the secondary and read-only instances based on their assigned read weights.
Benefits
-
Unified endpoint for easy maintenance
By connecting to a single read-only routing endpoint, you can perform read operations on your read-only instances, which reduces maintenance costs. You can also scale read capacity by adding more read-only instances without modifying your application code.
-
Customizable weights for various use cases
You can customize the read weight of each read-only instance to meet the demands of different application scenarios.
-
Automatic health checks for high availability
The read/write splitting feature automatically performs a health check on all read-only instances. If an instance fails or if replication latency exceeds a specified threshold, the system stops routing read requests to that instance. Instead, it distributes the requests among the remaining healthy instances. This process ensures that a single instance failure does not disrupt your application. When the instance is restored, RDS automatically adds it back to the request distribution pool.
NoteTo avoid a single point of failure, we recommend that you create at least two read-only instances for a primary instance.
Read-only and network endpoints
Read-only endpoints include a unified read-only routing endpoint and a secondary instance endpoint:
-
Unified read-only routing endpoint: Configure this endpoint in your application to implement read/write splitting. When clients send read requests to this endpoint, it automatically distributes them to the secondary and read-only instances based on their read weights.
-
Secondary instance endpoint: Configure this endpoint in your application to directly access the secondary instance. When you use this endpoint, you cannot access the primary instance or read-only instances.
If your application uses only the endpoint of the primary instance, it sends all requests to that instance.
Prerequisites
The primary RDS for SQL Server instance must meet the following requirements. You can view this information on the Basic Information page of your instance.
-
Engine Version: 2017 RDS Cluster Edition, 2019 RDS Cluster Edition, 2022 RDS Cluster Edition, or 2025 RDS Cluster Edition
-
Instance Series: RDS Cluster Edition
-
Storage Type: ESSD or Ultra Disk
-
Billing Method: subscription or pay-as-you-go. Serverless instances are not supported.
Usage notes
-
You cannot manually modify the read-only routing endpoint.
-
Enabling and using read-only endpoints is free of charge. You are only charged for the read-only instances.
-
Read-only routing endpoints do not support the classic network.
-
If the primary instance becomes unavailable due to a network failure or other reasons, the system automatically triggers a failover. The system promotes the secondary instance to the primary role to ensure service availability. During this process, the read and write weights of the primary and secondary instances are automatically switched so that the original secondary instance can process read and write requests and ensure service continuity.
Meanwhile, the system automatically repairs the original primary instance. During the repair process, its status changes to Instance in Maintenance. During this time, you cannot perform operations such as upgrading its specifications or changing read weights. After the repair is complete, the system initiates another failover to switch the roles back. The read weights are also reverted, and the instance status returns to Running.
Enable the unified read-only routing endpoint
Enable the unified read-only routing endpoint and configure the read weights. The system then processes read requests based on the configured weights.
Log on to the ApsaraDB RDS console and 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 instance ID.
-
In the navigation pane on the left, click Cluster Management. Then, click Open the unified read-only network address.
-
In the dialog box that appears, set the endpoint type and configure the read weight for each node (primary, secondary, and read-only instances). Then, click OK.
The primary and secondary nodes are part of the RDS Cluster Edition architecture. You create read-only instances manually. For more information, see RDS Cluster Edition architecture.
Parameter
Description
Endpoint Type:
-
Internal (VPC): Used for internal connections from other Alibaba Cloud services, such as ECS instances, within the same VPC.
-
Internet Address: Used when your application is deployed in a different VPC or on an on-premises machine and needs to access the instance over the internet.
NoteDue to the potential for network instability over the public network, we recommend using an internal endpoint for your application. For more information, see Differences between internal and public endpoints.
Weight Distribution
The roles that participate in weight allocation include the primary node, the secondary node, and read-only instances (if they exist). A higher read weight means the instance processes more read requests. For example, if a primary instance has three read-only instances with read weights of 100, 200, and 200, the read requests are distributed among them at a ratio of 1:2:2.
-
Automatic Distribution: The system automatically assigns a read weight to each read-only instance based on its specifications.
The system also automatically sets the weights for new read-only instances. For more information, see System weight allocation rules.
-
Customized Distribution: Manually set the read weight for each node. The value can range from 0 to 10,000.
The read weight of a new read-only instance defaults to 0 and must be modified manually.
ImportantIf a read-only instance in the cluster is released, the system automatically removes its weight allocation.
-
Enable the secondary instance endpoint
-
Go to the RDS Instances page. In the top navigation bar, select the region where your target instance is located. Then, click the ID of the instance.
-
In the navigation pane on the left, click Cluster Management. Then, click Open backup instance address.
-
Select an Endpoint Type::
-
Internal (VPC): Used for internal connections from other Alibaba Cloud services, such as ECS instances, within the same VPC.
-
Internet Address: Used when your application is deployed in a different VPC or on an on-premises machine and needs to access the instance over the internet.
-
-
Click OK.
Cluster information
On the Cluster Management page, you can view the basic information and configuration list of the cluster.
Basic cluster information
The basic cluster information includes Network of Primary Instance, Backup instance network information, and Unified read-only network information.
The Primary Instance Network Information section lists the Internal Endpoint, Internal Port, Public Endpoint, Public Port, and Network Type (VPC). Controlled by the Disable Secondary Instance Endpoint switch, the Secondary Instance Network Information section shows the Secondary Instance Endpoint, Port, and Network Type. Controlled by the Disable Read-only Routing Endpoint switch, the Read-only Network Information section displays the Read-only Routing Endpoint, Port, Network Type, Weight Distribution Mode, and Number of Participating Instances.
Cluster configuration list
The instance list displays all nodes and instances within the cluster, along with their Running status, Role, and Read Weight. You can view and manage instances with different roles in this list.
In addition to Status, Role, and Read Weight, the cluster node list also includes columns such as Instance ID, Instance Specifications, Region & Zone, and VSwitch. In this example, the primary node has a read weight of 0, and the secondary node has a read weight of 800. In the Actions column, you can click Modify Weight Distribution to configure the settings.
Related operations
-
If your business workload increases, you can modify the read weight distribution for the unified read-only routing endpoint. The endpoint then automatically forwards read requests to the secondary instance and all configured read-only instances based on the new weights. For more information, see Modify weight distribution.
-
If you no longer need the read/write splitting feature, you can disable it. For more information, see Disable read/write splitting (read-only routing endpoint).