Cloud-native API Gateway lets you add policies and configure plug-ins for APIs and operations to improve their security, performance, and maintainability.
Policy changes take effect immediately. You do not need to republish the API.
By default, the gateway applies API-level plug-in configurations at the operation level.
While you cannot delete API-level policies at the operation level, operation-level policies can override API-level policies.
Procedure
You can add an API policy in two ways: from outside an instance or from within an instance.
APIs outside an instance
Log on to the Cloud-native API Gateway console. In the left-side navigation pane, click API and select a region from the top menu bar.
Click the target API and select the target instance from the drop-down list.
APIs inside an instance
Log on to the Cloud-native API Gateway console. In the left-side navigation pane, click Instance and select a region from the top menu bar.
On the Instance page, click the ID of the target gateway instance. In the left-side navigation pane, click API, and then click the target API.
You can configure policies and plug-ins at the API level or the operation level:
API level: Click the API Policy Configuration tab to configure policies and plug-ins for all operations at the API level. Then, click Enable Policy/Plug-in.
Operation level: On the Operations tab, click the target operation. Click the Policy Configuration tab, and then click Enable Policy/Plug-in.
In the Enable Policy/Plug-in panel, select a policy or plug-in to configure. For more information, see Policy configuration and Plug-in configuration.
Policies
Throttling policy
Cloud-native API Gateway supports throttling policies at the API and operation levels. These policies prevent inbound requests from overwhelming your backend services and help you avoid cascading failures. In high-concurrency scenarios, throttling protects the availability of backend services by blocking some requests. This lets you precisely control the number of requests for each API and operation within a specific time period, ensuring that the number does not exceed a preset threshold.
Throttling policies include Concurrency Control, Traffic Control, and Circuit Breaking.
Concurrency control policy: This policy limits the number of concurrent requests. It works by counting the total number of requests currently being processed by the gateway. When this number reaches the configured threshold, the gateway immediately blocks new traffic. You can set this threshold to match the maximum concurrent requests that your backend service can handle to protect its availability during traffic spikes.
Traffic control policy: This policy limits the request rate based on queries per second (QPS). It works by monitoring the QPS for an API or operation. When the QPS reaches the configured threshold, the gateway immediately blocks new traffic. This prevents backend services from being overwhelmed by sudden traffic spikes and ensures high availability.
Circuit breaking policy: This policy protects backend services by monitoring the response time or error rate of APIs and operations. When a specified threshold is reached, the gateway "trips the circuit," immediately failing fast on requests to the unstable service to prevent further strain. After a configured duration, the gateway enters a "half-open" state and allows a limited number of test requests to see if the service has recovered. If the service is stable, the circuit closes; otherwise, it trips again.
Rewrite policy
A rewrite policy lets you modify the request path and hostname before forwarding the request to the backend service. This helps meet specific business and architectural requirements by ensuring that requests are routed to the correct service or endpoint.
Header modification policy
The header modification feature lets you change request headers before it is forwarded to the backend service, or in a response before it is returned to the client.
CORS policy
Cross-origin resource sharing (CORS) is a security feature that lets a web application server control cross-origin access, enabling secure data transfer. Cloud-native API Gateway supports CORS policies at the API and operation levels. You can specify which domains and request methods can access your resources.
The CORS policy does not take effect for mock services. You must configure an actual backend service for testing.
Traffic replication policy
The traffic replication policy lets you copy live application traffic to a specified service. This feature is useful for simulation testing and issue diagnosis, to help you evaluate application performance and troubleshoot failures.
Timeout policy
Cloud-native API Gateway provides timeout settings at the API and operation levels. You can configure the maximum time that the gateway waits for a response from the backend service. If the gateway does not receive a response within the specified time, it returns an HTTP 504 (Gateway Timeout) status code to the client.
Retry policy
Cloud-native API Gateway provides retry settings at the API and operation levels to automatically retry failed requests. You can configure retry conditions, such as triggering a retry on a connection failure, an unavailable backend service, or a specific HTTP status code.
Plug-ins
Click the Add Plug-in tab.
In the Quick Navigation section, select a plug-in type or search for a plug-in by name, and then click the plug-in card:
If the plug-in is not installed, click Install and Configure in the pop-up dialog box. In the subsequent dialog box, configure the plug-in rules and enable it.
If the plug-in is already installed, configure the plug-in rules and enable it in the pop-up dialog box.
Click OK to return to the attachment list for the API, where you can view the attachment and enablement status of plug-ins for the operations.
The attachment list is a flowchart. It includes four blocks: Frontend API, Inbound Processing, Backend Service, and Outbound Processing. Arrows between the blocks show the request flow. Each processing block lists attached plug-ins, and you can add more by clicking the Enable Policy/Plug-in link.