All Products
Search
Document Center

ApsaraDB RDS:Enable the read-only routing endpoint to implement read/write splitting

Last Updated:Aug 29, 2023

ApsaraDB RDS for SQL Server allows you to manage read-only RDS instances in your database system and provides a read-only routing endpoint. You can add the endpoint of the primary RDS instance and the read/write splitting endpoint to your application to implement read/write splitting.

Prerequisites

  • Your RDS instance is a primary RDS instance and meets the following requirements:

    • The primary RDS instance runs SQL Server 2017 EE on RDS Cluster Edition, SQL Server 2019 EE on RDS Cluster Edition, or SQL Server 2022 EE on RDS Cluster Edition.

    • The primary RDS instance runs RDS Cluster Edition.

    • The primary RDS instance uses enhanced SSDs (ESSDs).

    Note

    You can go to the Basic Information page of the RDS instance to view the preceding information.

  • The primary RDS instance has at least one read-only RDS instance. For more information about how to create a read-only RDS instance, see Create a read-only ApsaraDB RDS for SQL Server instance.

Usage notes

  • If this is the first time you enable the read-only routing endpoint, the system automatically upgrades the control and management systems of the primary and read-only RDS instances to the latest versions. This ensures service availability. When you enable the read-only routing endpoint, the primary RDS instance encounters a transient connection that last for approximately 30 seconds. During this period, all read-only RDS instances of the primary RDS instance are inaccessible. We recommend that you enable the read-only routing endpoint during off-peak hours and make sure that your application is configured to automatically reconnect to your RDS instance. This prevents interruptions to your workloads.

  • If you restarted the primary RDS instance for which you want to enable the read-only routing endpoint and its read-only RDS instances or changed the specifications of the RDS instances at least once after March 08, 2017, the control and management systems of the RDS instances have been upgraded to the latest versions. When you enable the read-only routing endpoint, the system does not restart the RDS instances and no transient connections occur.

  • The read-only routing endpoint does not change after it is generated. It does not change even when you enable or disable the read-only routing endpoint multiple times. You do not need to update the configuration data on your application on a regular basis. This reduces maintenance costs.

    Note

    The read-only routing endpoint cannot be manually modified.

  • The read-only routing endpoint is free of charge. However, you still need to pay for the read-only RDS instances that you use. For more information, see Overview of read-only ApsaraDB RDS for SQL Server instances.

  • The read-only routing endpoint is not supported in the classic network.

Enable the read-only routing endpoint

  1. 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.
  2. In the left-side navigation pane, click Cluster management.

  3. Click Enable now..

  4. In the Configure Readonly Splitting Address dialog box, configure the following parameters.

    Parameter

    Description

    Network Type

    The type of the read-only routing endpoint.

    • Intranet address (VPC): RDS instances that run SQL Server 2017 EE or SQL Server 2019 EE support only the virtual private cloud (VPC) network type. Therefore, the read-only routing endpoint must be of the VPC network type.

    • Internet Address: This type of endpoint is used to connect to RDS instances over the Internet. We recommend that you use internal read-only routing endpoints to connect to RDS instances because connections over the Internet are prone to fluctuations.

    Read Weight Distribution

    The read weight of each RDS instance. A higher read weight indicates more read requests to process. For example, if the primary RDS instance has three read-only RDS instances whose read weights are 100, 200, and 200, the read-only RDS instances process read requests at a ratio of 1:2:2.

    • Automatic Distribution: The system automatically assigns a read weight to each RDS instance based on the instance specifications. After you create a read-only RDS instance, the system automatically assigns a read weight to the created read-only RDS instance. You do not need to manually specify a read weight for the created read-only RDS instance. For more information, see Default read weights.

    • Customized Distribution: You must manually specify the read weight of each read-only RDS instance. Valid values: 0 to 10000. After you create a read-only RDS instance, the system sets the read weight of the read-only RDS instance to 0. You must manually modify the read weight of the created read-only RDS instance.

  5. Click OK.

What to do next

  • On the Cluster management page, view the ID, status, and read weight of the read-only RDS instance. On the Cluster management page, find the read-only RDS instance that you want to manage and click Manage in the Actions column to manage the instance.

  • After you add the endpoint of the primary RDS instance and the read-only routing endpoint to your application, the system forwards write requests to the endpoint of the primary RDS instance and read requests to the read-only routing endpoint. Then, the read-only routing endpoint distributes the read requests to the read-only RDS instances based on the weights of the read-only RDS instances.