WSO2 API Manager provides the ability to control the number of successful hits to an API during a given period which you can enable at runtime. To protect your APIs and regulate traffic and access to the resources, you can engage throttling policies not only in the API creation and publishing state. But also for te published APIs at runtime.
The steps below show how to engage a throttling policy to an API at runtime.
Write a new throttling policy. For example, the following sample throttling policy points to a backend service and allows 1000 concurrent requests to a service.
- Log in to the API Manager's management console (
- Click the
/_system/goverence/apimgt/applicationdatapath to go to its detailed view.
In the detail view, click the Add Resource link.
Upload the policy file to the server as a registry resource.
In the management console, select the Service Bus > Source View menu.
The configurations of all APIs created in the API Manager instance opens. To engage the policy to a selected API, add it to your API definition. In this example, we add it to the login API.
Note: Be sure to specify the same path used in step 5 in the policy key of your API definition. Also, use the same tier name you selected when creating the API as the throttle id in the policy (example <throttle:ID throttle:type ="ROLE">Gold</throttle:ID>).
You have successfully engaged a throttling policy to an API at runtime, without restarting the server.