All Products
Search
Document Center

API Gateway:Throttling

Last Updated:May 27, 2020

Throttling is now integrated into the plug-in system. The original throttling interface and console are still in use. Throttling policies and throttling plug-ins belong to the same plug-in type and are subject to the binding restrictions of that type.

When you create or modify throttling policies in the original throttling interface or console, the data changes are synchronized to the plug-in system. However, the changes you made in the plug-in system cannot be synchronized to the throttling interface or console.

Notes

In a throttling policy, you can configure API-, user-, and application-level throttling thresholds and a time unit, which can be second, minute, hour, or day. Before using throttling policies, you need to be familiar with the following content:

A throttling policy can include the following throttling thresholds:

  • API-level throttling threshold: The maximum number of times that an API bound with the throttling policy can be called within a time unit. This time unit can be second, minute, hour, or day. For example, you can set this threshold to 5,000 times per minute.
  • Application-level throttling threshold: The maximum number of times that each application can call an API bound with the throttling policy within a time unit. For example, you can set this threshold to 50,000 times per hour.
  • User-level throttling threshold: The maximum number of times that each Alibaba Cloud account can call an API bound with the throttling policy within a time unit. An Alibaba Cloud account may have multiple applications. The throttling threshold of an Alibaba Cloud account is the sum of throttling thresholds of all the applications under this account. For example, you can set the user-level throttling threshold to 500,000 times per day.

These three thresholds can exist simultaneously in a throttling policy. Note: The user-level throttling threshold cannot be greater than the API-level throttling threshold, and the application-level throttling threshold cannot be greater than the user-level throttling threshold. That is, the application-level throttling threshold must be less than or equal to the user-level throttling threshold, and the user-level threshold must be less than or equal to the API-level throttling threshold.

You can also add special applications or users to a throttling policy. The basic API-level throttling threshold in the throttling policy applies to the added special applications or users. You need to set a special throttling threshold for each special application or user, and this special throttling threshold must not be greater than the API-level throttling threshold. The application- and user-level throttling thresholds in the throttling policy do not apply to the special applications or users.

Plug-in configurations

You can configure throttling plug-ins in the JSON or YAML format as these two formats use the same schema. You can use the yaml to json tool to convert the configuration format of a throttling plug-in. The following table describes a plug-in configuration template in the YAML format.

  1. ---
  2. unit: SECOND #The time unit. Valid values: SECOND, MINIUTE, HOUR, and DAY.
  3. apiDefault: 1000 #The API-level throttling threshold.
  4. userDefault: 30 # (Optional) The default user-level throttling threshold. Value 0 indicates that no user-level throttling is implemented. The user-level threshold must not be greater than the API-level throttling threshold.
  5. appDefault: 30 # (Optional) The application-level throttling threshold. Value 0 indicates that no application-level throttling is implemented. The application-level throttling threshold must not be greater than the API-level throttling threshold.
  6. specials: # (Optional) The special throttling settings. You can set special throttling thresholds for special applications or users in the throttling policy.
  7. - type: "APP" # Special throttling is implemented for special applications.
  8. policies:
  9. - key: 10123123 # An application ID. You can log on to the API Gateway console, choose Consume APIs > APPs from the left-side navigation pane, and click an application name to go to the application details page to obtain the application ID.
  10. value: 10 # The special throttling threshold to be implemented for the special application. This value cannot exceed the API-level throttling threshold in the throttling policy.
  11. - key: 10123123 # An application ID.
  12. value: 10 # The special throttling threshold to be implemented for the special application. This value cannot exceed the API-level throttling threshold in the throttling policy.
  13. - type: "USER" # Special throttling is implemented for special Alibaba Cloud accounts.
  14. policies:
  15. - key: 123455 # An Alibaba Cloud account ID. You can click the user icon in the upper-right corner of the page in Alibaba Cloud Management Console to obtain your Alibaba Cloud account ID.
  16. value: 100 # The special throttling threshold to be implemented for the specified Alibaba Cloud account. This value cannot exceed the API-level throttling threshold in the throttling policy.