Updated on 2024-04-03 GMT+08:00

Implementation Procedure

  1. 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.

  2. 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

  3. Configure parameter-based throttling.

    1. As required in 2, enable parameter-based throttling, and define the header and rule.
      1. Click Add Parameter, select header for Parameter Location, and enter Host for Parameter.
      2. 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.
      3. 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.
    1. As required in 3 and 4, define multiple rules with parameter Path.
      1. 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.
      2. Add these three condition expressions: reqPath = /fc, reqPath = /list, and method = get.
      3. Click Set Lower Level.
      4. Put the two reqPath expressions in an OR relationship. This means the condition is met when either of the two paths is matched.
      5. Select reqPath = /list and method = get, click Set Lower Level, and select AND.

      6. 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.

  4. 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

  5. Click OK. The request throttling 2.0 policy is configured.
  6. Bind this policy to an API.

    1. Click the policy name to go to the policy details page.
    2. In the APIs area, select environment RELEASE and click Bind to APIs. Select an API and click OK.

  7. Verify the API.

    Call the API and verify whether the request throttling 2.0 policy has taken effect.