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¶
Parameter | Description |
---|---|
Name | Request throttling policy name. |
Type | API-based or API-shared request throttling.
|
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 | 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.
|
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.
|
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.
|
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.
On the request throttling policy details page, click the Excluded Credentials tab.
Click Select Excluded Credential.
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¶
On the request throttling policy details page, click the Excluded Tenants tab.
Click Select Excluded Tenant.
Enter the tenant information.
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.