Implementation Procedure
- Create a policy.
Log in to the APIG console and create a request throttling 2.0 policy. For details, see Request Throttling 2.0 in the API Gateway User Guide.
In the navigation pane, choose API Management > API Policies. Click Create Policy, and select Request Throttling 2.0.
Configure basic policy information to meet your demands.Table 1 Policy basic Information Parameter
Description
Name
Enter a name that conforms to specific rules to facilitate search.
Throttling
Select High-performance.
Policy Type
Select API-specific, which means measuring and throttling requests of a single API.
Period
Throttling period. Set this parameter to 60s.
- Configure basic throttling.
As required in 1, set Max. API Requests to 10 times per 60s and Max. User Requests to 5 times per 60s.
Table 2 Basic throttling Parameter
Description
Max. API Requests
10
Max. User Requests
5
- Configure parameter-based throttling.
- As required in 2, enable parameter-based throttling, and define the header and rule.
- Click Add Parameter, select header for Parameter Location, and enter Host for Parameter.
- In the Rules area, click Add Rule, and set Max. API Requests to 10 and Period to 60 seconds. Then click , and set the matching condition Host = www.abc.com.
- Click OK. The header matching rule Host = www.abc.com is generated, indicating that an API bound with this policy can only be called 10 times per 60s by requests whose Host header is www.abc.com.
- As required in 3 and 4, define multiple rules with parameter Path.
- In the Rules area, click Add Rule, and set Max. API Requests to 10 and Period to 60 seconds. Then click to open the Condition Expressions dialog box.
- Add these three condition expressions: reqPath = /fc, reqPath = /list, and method = get.
- Click Set Lower Level.
- Put the two reqPath expressions in an OR relationship. This means the condition is met when either of the two paths is matched.
- Select reqPath = /list and method = get, click Set Lower Level, and select AND.
- Click OK. It indicates that APIs with path /list and method GET or APIs with path /fc bound with this policy can only be called 10 times per 60s.
- As required in 2, enable parameter-based throttling, and define the header and rule.
- Configure excluded throttling.
As required in 5, enable excluded throttling. Add an excluded tenant with a threshold of 5 requests per 60s.
Table 3 Excluded throttling Parameter
Description
Account ID
Tenant ID
Threshold
5
- Click OK. The request throttling 2.0 policy is configured.
- Bind this policy to an API.
- Click the policy name to go to the policy details page.
- In the APIs area, select environment RELEASE and click Bind to APIs. Select an API and click OK.
- Verify the API.
Call the API and verify whether the request throttling 2.0 policy has taken effect.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot