API traffic governance

更新时间:
复制 MD 格式

On the API details page, you can manage traffic for the API by configuring rate limiting and caching.

Rate limiting

Rate limiting restricts requests from the gateway to the backend cluster. The procedure is as follows:

Note

API Gateway currently supports only single-instance rate limiting. This limits requests that pass through a single gateway container, not a cluster, to the backend cluster.

  1. On the API details page, switch to the Traffic Governance tab.

  2. Click the icon to the right of Rate Limiting to edit the configuration:

    • Rate Limiting Status: Set the status to On.

    • Threshold (QPS): The maximum number of requests allowed per second. Requests that exceed this value are rate-limited. Only positive integers are supported.

    • Abnormal Response Type: Select Return Data or Return Gateway Response Code.

  3. Click Confirm.

Cache

Caching allows the gateway to store content from the backend. This reduces the load on the backend server.

The procedure is as follows:

  1. On the API details page, switch to the Traffic Governance tab.

  2. Click the icon to the right of Cache to edit the configuration:

    • Result Cache: Set the status to On.

    • Cache Duration: The length of time to cache content on the gateway, in seconds (s). The maximum duration is 5 minutes.

    • Cache Key: Configure the location and value of the cache key. Supported locations include HEADER, QUERY, COOKIE, and BODY.

      Note

      If you select BODY, the BODY must be a JSON string. The Protocol Buffers (pb) format for the BODY is not currently supported.

  3. Click Confirm.