API traffic governance
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:
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.
On the API details page, switch to the Traffic Governance tab.
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.
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:
On the API details page, switch to the Traffic Governance tab.
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.
NoteIf you select BODY, the BODY must be a JSON string. The Protocol Buffers (pb) format for the BODY is not currently supported.
Click Confirm.