You can call the AllocateReadWriteSplittingConnection operation to apply for a read-only routing endpoint for a primary ApsaraDB of RDS instance.

This operation is supported only for primary instances that run SQL Server. After you apply for a read-only routing endpoint for a primary instance, the existing endpoints of the primary instance and its read-only instances remain valid. In addition, you can still apply for an internal or public endpoint.

Before you call this operation, make sure that the following requirements are met:

  • The primary instance must be in the Running state.
  • The primary instance must be attached with read-only instances.
  • The primary instance cannot have ongoing migration tasks.
  • The primary instance must run SQL Server 2017 EE.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AllocateReadWriteSplittingConnection

The operation that you want to perform. Set the value to AllocateReadWriteSplittingConnection.

DBInstanceId String Yes rm-uf6wjk5xxxxxxx

The ID of the primary instance.

ConnectionStringPrefix String No rr-m5exxxxx-rw.mysql.rds.aliyuncs.com

The prefix of the read-only routing endpoint. The prefix must be unique. It can be up to 30 characters in length and can contain lowercase letters and hyphens (-). It must start with a lowercase letter.

Note The default prefix consists of the name of the primary instance followed by the letters rw.
Port String No 1433

The port that is associated with the read-only routing endpoint. Valid values: 1000 to 5999. Default value: 1433.

MaxDelayTime String No 30

The threshold of the latency that is allowed on the read-only instances. Valid values: 0 to 7200. Default value: 30. Unit: seconds.

Note If the latency on a read-only instance exceeds the specified threshold, ApsaraDB for RDS does not route read requests to the read-only instance.
NetType String No Intranet

The network type of the read-only routing endpoint. Valid values:

  • Internet
  • Intranet

The default value is Intranet. Make sure that the network type of the read-only routing endpoint is the same as that of the primary instance.

DistributionType String No Standard

The method that is used to assign read weights. Valid values:

  • Standard: ApsaraDB for RDS automatically assigns a read weight to each instance based on the instance specifications.
  • Custom: You must manually specify the read weight of each instance.
Weight String No {"Instanceid1":"100","Instanceid2":"200"}

The read weights of the primary instance and its read-only instances. The read weight of an instance must be a multiple of 100. The maximum value is 10000. Format: {"Instanceid1":"Weight","Instanceid2":"Weight"...}.

Note
  • This parameter must be specified if you set the DistributionType parameter to Custom.
  • This parameter is invalid if you set the DistributionType parameter to Standard.

Response parameters

Parameter Type Example Description
RequestId String 4C467B38-3910-447D-87BC-AC049166F216

The ID of the request.

Examples

Sample requests

http(s)://rds.aliyuncs.com/? Action=AllocateReadWriteSplittingConnection
&DBInstanceId=rm-uf6wjk5xxxxxxx
&<Common request parameters>

Sample success responses

XML format

<AllocateReadWriteSplittingConnectionResponse>
	  <RequestId>4C467B38-3910-447D-87BC-AC049166F216</RequestId>
</AllocateReadWriteSplittingConnectionResponse>

JSON format

{
    "RequestId": "4C467B38-3910-447D-87BC-AC049166F216"
}

Error codes

For a list of error codes, visit the API Error Center.