All Products
Search
Document Center

Alibaba Cloud SDK:Advanced backoff mechanism based on the throttling policy

Last Updated:Jun 16, 2026

The advanced backoff mechanism uses server-side throttling information to calculate retry intervals and manage API request rates during throttling cycles.

Note

The retry mechanism and the throttling policy are added. For more information, see Retry mechanism.

The core library aliyun-java-sdk-core V4.6.0 and later supports the retry mechanism and provides an advanced backoff mechanism based on the throttling policy. For more information, see Retry mechanism. Add the following Maven dependency:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.6.0</version>
</dependency>
Important
  1. Not all API operations support the advanced backoff mechanism. To check whether an API operation supports this mechanism, see the Quotas Info section in the API documentation of the corresponding service. For example, see the Quotas Info section in the DescribeHpcClusters topic of Elastic Compute Service (ECS).

  2. You can enable this mechanism in the SDK regardless of whether the API operations support it. If the API operations do not support this mechanism, the backoff policy and the request-disabling policy do not take effect. However, if the API operations later begin to support this mechanism, the throttling policy and request-disabling policy may be unexpectedly triggered, making issue troubleshooting more difficult.

  3. After you enable this mechanism, we recommend that you continue to monitor failed API calls. Relying solely on the backoff mechanism may make issues harder to troubleshoot.

  4. The prerequisite of the following examples is that the API operations support the backoff mechanism based on the throttling policy.

Overview

The advanced backoff mechanism includes two policies:

  • Backoff policy

  • Policy of disabling API requests during throttling

Retry intervals are calculated by using the EqualJitter exponential backoff algorithm. For more information, see Retry mechanism. The advanced backoff mechanism further adjusts intervals based on server-side throttling information.

Enable the backoff policy based on the throttling policy

By default, the throttling-based backoff policy is disabled. You can enable it by using one of the following methods:

  1. Configure a retry policy.

RetryPolicy retryPolicy = RetryPolicy.builder()
                .maxNumberOfRetries(3) // The maximum number of retries.
                .maxDelayTimeMillis(20 * 1000) // The maximum retry interval. Unit: milliseconds. If the interval is exceeded, no retries are performed.
                //.retryConditions(retryConditions) // The policy that is used to trigger retries.
                .enableAliyunThrottlingControl(true) // Enable the backoff policy based on the throttling policy. 
                //.throttlingConditions(throttlingConditions) // The policy that is used to restrict retries.
                .build();

request.setSysRetryPolicy(retryPolicy);
  1. Use the default retry policy.

// The default policy. The request parameter is enableAliyunThrottlingControl. The value true specifies that the backoff policy based on the throttling policy is enabled. The value false specifies that the backoff policy based on the throttling policy is disabled.
RetryPolicy retryPolicy = RetryPolicy.defaultRetryPolicy( 
true 
);

request.setSysRetryPolicy(retryPolicy);

Benefits of enabling the backoff policy based on the throttling policy

  1. Reduces unnecessary retries and lowers system resource consumption.

  2. Calculates more accurate backoff intervals, which improves retry success rates.

Advanced settings

Backoff policy: Calculate backoff time based on the throttling policy

When the throttling-based backoff policy is enabled, backoff time is calculated as follows:

  1. If no throttling is triggered, EqualJitter is used to calculate a retry interval.

  2. If throttling is triggered, the retry interval is the larger value between the remaining time of the current throttling cycle and the EqualJitter result. If this interval exceeds the maximum retry interval, an exception is thrown and the remaining throttling cycle time is cached for use by the request-disabling policy.

Policy of disabling API requests during throttling

When the throttling-based backoff policy is enabled and throttling is triggered, the server returns remaining quota information in the response header. This information includes the remaining number of API calls and the remaining time of the current throttling cycle, reported in the "User" and "API + User" dimensions. If API calls are throttled, the remaining call count is 0.

Note

Keys that correspond to the two dimensions in the header:

  • "API + User" dimension: X-RateLimit-User-API

  • "User" dimension: X-RateLimit-User

Example of the "API + User" dimension:

"X-RateLimit-User-API" : "Remain:1,Limit:2,Time:1000,TimeLeft:122,Reset:1637835220000"

Remain: the remaining number of API calls. The value of the Remain parameter is of the INT type. If the value is -1, the remaining number of API calls is sufficient. If API calls are throttled, the value 0 is returned.

Limit: the maximum throttling threshold. The value is of the INT type.
Time: the time span of throttling. The value is of the LONG type. Unit: milliseconds.
TimeLeft: the remaining time of the current throttling cycle. The value is of the LONG type. Unit: milliseconds.
Reset: the start time of the next throttling cycle. The value is of the LONG type and is a timestamp in milliseconds

.

The SDK tracks the remaining time of the current throttling cycle and blocks new calls or retries during that period. If the remaining time exceeds the maximum retry interval, an error is thrown. Otherwise, the system waits until the throttling cycle ends before initiating or retrying the call.

Enable throttling debugging

To retrieve throttling quota information without waiting for throttling to be triggered, set X-RateLimit-Mode to debug in the request header.

request.putHeadParameter("X-RateLimit-Mode", "debug");

The remaining quota information is then included in the response header of each API call.