Request Throttling

Request throttling limits the number of times APIs can be called by a user or app within a specific time period to protect backend services. The throttling can be down to the minute or second. To ensure service continuity of an API, create a request throttling policy for the API.

Usage Guidelines

  • You have understood the guidelines for policy creation and API binding.

  • Adding a request throttling policy to an API means binding them to each other. An API can be bound with only one request throttling policy for a given environment, but each request throttling policy can be bound to multiple APIs.

  • For APIs not bound with a request throttling policy, the throttling limit is the value of ratelimit_api_limits set on the Parameters page of the gateway.

Configuration Parameters

Table 1 Configuration parameters

Parameter

Description

Name

Request throttling policy name.

Type

API-based or API-shared request throttling.

  • API-specific: Request throttling is based on every API to which the policy is bound.

  • API-sharing: Request throttling is based on all APIs as a whole to which the policy is bound.

Period

For how long you want to limit the number of API calls. This parameter can be used together with the following parameters:

  • Max. API Requests: Limit the maximum number of times an API can be called within a specific period.

  • Max. User Requests: Limit the maximum number of times an API can be called by a user within a specific period.

  • Max. Credential Requests: Limit the maximum number of times an API can be called by a credential within a specific period.

  • Max. IP Address Requests: Limit the maximum number of times an API can be called by an IP address within a specific period.

Max. API Requests

The maximum number of times each bound API can be called within the specified period.

This parameter must be used together with Period.

Max. User Requests

The maximum number of times each bound API can be called by a user within the specified period. This limit only applies to APIs that are accessed through app or IAM authentication.

  • The value of this parameter cannot exceed that of Max. API Requests.

  • This parameter must be used together with Period.

  • If there are many users under your account that access an API, the request throttling limits of the API will apply to all these users.

Max. Credential Requests

The maximum number of times each bound API can be called by a credential within the specified period. This limit only applies to APIs that are accessed through app authentication.

  • The value of this parameter cannot exceed that of Max. User Requests or Max. API Requests.

  • This parameter must be used together with Period.

Max. IP Address Requests

Maximum times that an API can be requested by an IP address. You can configure the real_ip_from_xff parameter of the gateway to use the IP address in the X-Forwarded-For header as the basis for request throttling.

  • The value of this parameter cannot exceed that of Max. API Requests.

  • This parameter must be used together with Period.

Description

Description of the request throttling policy.

Follow-Up Operations

  • To control the traffic of a credential, bind a request throttling policy to the credential by referring to Binding a Request Throttling Policy to a Credential. Traffic of the credential is limited by the excluded credential threshold, while traffic of APIs and users are still limited by the request throttling policy.

  • To control the traffic of a tenant, bind a request throttling policy to the tenant by referring to Binding a Request Throttling Policy to a Tenant. Traffic of the tenant is limited by the excluded tenant threshold, while traffic of APIs and users are still limited by the request throttling policy.

Binding a Request Throttling Policy to a Credential

You have created a credential or obtained a credential ID from other tenants.

  1. On the request throttling policy details page, click the Excluded Credentials tab.

  2. Click Select Excluded Credential.

  3. Select a credential to exclude. You can use one of the following methods:

    • To select an existing credential, click Existing, select a credential, and enter a threshold.

    • To select a credential of other tenants, click Cross-tenant, and enter the credential ID and a threshold.

    Note

    Excluded credential thresholds take precedence over the value of Max. Credential Requests.

    For example, a request throttling policy has been configured, with Max. API Requests being 10, Max. Credential Requests being 3, Period being 1 minute, and two excluded credentials (max. 2 API requests for credential A and max. 4 API requests for credential B). If the request throttling policy is bound to an API, credential A and B can access the API 2 and 4 times within 1 minute, respectively.

Binding a Request Throttling Policy to a Tenant

  1. On the request throttling policy details page, click the Excluded Tenants tab.

  1. Click Select Excluded Tenant.

  2. Enter the tenant information.

    Table 2 Excluded tenant configuration

    Parameter

    Description

    Tenant ID

    Account ID or project ID. For details, see the description about Excluded Tenants in Table 1.

    Threshold

    The maximum number of times an API can be called by the tenant within a specified period.

    The value of this parameter cannot exceed that of Max. API Requests.

  3. Click OK.

    Note

    Excluded tenant thresholds take precedence over the value of Max. User Requests.

    For example, a request throttling policy has been configured, with Max. API Requests being 10, Max. User Requests being 3, Period being 1 minute, and two excluded tenants (max. 2 API requests for tenant A and max. 4 API requests for tenant B). If the request throttling policy is bound to an API, tenants A and B can access the API 2 and 4 times within 1 minute, respectively.