You can call the CalculateDBInstanceWeight operation to query the read weights of a primary ApsaraDB RDS instance and its read-only instances.

When the read/write splitting feature is enabled, this operation is used to calculate system-specified read weights. For more information, see Read/write splitting overview. For more information about custom read weights, see DescribeDBInstanceNetInfo.

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

  • The shared proxy feature must be enabled for the primary instance.
  • The primary instance must run one of the following database engine versions and RDS editions:
    • MySQL 5.7 on RDS High-availability Edition (with local SSDs)
    • MySQL 5.6
    • SQL Server 2017 on RDS Cluster Edition


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

Request parameters

Parameter Type Required Example Description
Action String Yes CalculateDBInstanceWeight

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

DBInstanceId String Yes rm-uf6wjk5xxxxxxx

The ID of the primary instance.

Response parameters

Parameter Type Example Description
Items Array of DBInstanceWeight

An array that consists of the system-specified read weights.

DBInstanceId String rm-uf6wjk5xxxxxxx

The ID of the instance.

DBInstanceType String Master

The role of the instance. Valid values:

  • Master: The instance is primary.
  • Readonly: The instance is read-only.
Weight String 100

The read weight that ApsaraDB RDS calculates in real time for the instance.

ReadonlyInstanceSQLDelayedTime String 30

The threshold for the latency of data replication from the primary instance to the read-only instances. The read-only instances start to synchronize data from the primary instance after the time specified by the ReadonlyInstanceSQLDelayedTime parameter elapses. Unit: seconds.

RequestId String C816A4BF-A6EC-4722-95F9-2055859CCFD2

The ID of the request.


Sample requests

http(s):// Action=CalculateDBInstanceWeight
&<Common request parameters>

Sample success responses

XML format


JSON format

    "items": [
            "DBInstanceId": "rm-uf6wjk5xxxxxxx",
            "DBInstanceType": "Master",
            "Weight": "",
            "Availability": ""
    "requestId": "C816A4BF-A6EC-4722-95F9-2055859CCFD2"

Error codes

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