Hello, I have created Product with 4 API proxies. In the documentation (http://docs.apigee.com/api-services/reference/quota-policy), I have found that: "Quota counters are scoped to the API proxy that contains the Quota policy. If multiple API proxies contain Quota policies with the same name, the counters are maintained separately." Does it mean that I cannot use 1 quota for the whole Product? Could you suggest how should I achieve it, please?
Regards,
Andrzej
Solved! Go to Solution.
@Andrzej Currently the concept of a global quota counter doesn't exist, which means you would have quota counters being maintained at each api proxy level. So even if you have 1 api product and that enforcing quota across multiple api proxies, each would have their own counters rather than a shared counter. However there are ways to work around this problem.
We have a concept of proxy chaining which can help in these cases. You can have an apiproxy which enforces the quota policy and other proxies which make a callout (service callout) to this policy in the request preflow. This way you are not duplicating the policy definitions across multiple api proxies and at the same time being able to leverage the shared quota. I am attaching an example for you:
Here's my apiproduct configuration:
I have created a developer app using this apiproduct - "quota". And then I have created 2 api proxies, api_v1 and api_v2 which use proxy chaining underneath to call the Quota_v1 apiproxy using a service callout which enforces the quota. You would see the quota getting enforced for api_v1 and api_v2 both because the quota counters are now being maintained at "Quota_v1" api proxy level. Just to show the benefit of proxy chaining, I have also added a verifyApiKey policy in the Quota_v1 proxy which gets enforced for both the api_v1 and api_v2.
Let me know if this works for you. If this resolves your query, kindly accept the answer by clicking on the "Accept" option below:
You can also find out more about proxy chaining here or in my community post about proxy chaining here
Hi @Andrzej, you are right, Quota do not span across proxies.
Hence to achieve your usecase - you need a mechanism thro which API calls across proxies can be counted - I could think of ways to do that with the help of Proxy Chaining
one could be
> create a proxy with No Target, with just the Quota policy - enforcing the quota values configured at the API Product
> In all your other proxies, create a ServiceCallout with LocalTargetConnection to this Quota-proxy
This will enable the runtime to count all API calls across the proxies and hence apply quota for all proxies in a product
I understand, this is not very elegant - but just a workaround. But we have on our roadmap to address this issue
Thanks,
Mukundha